aw_test/models/
project.rs

1#![allow(unused)]
2use serde::{Deserialize, Serialize, Deserializer};
3use std::collections::HashMap;
4use serde_json::value::Value;
5use std::fmt::Display;
6use super::*;
7
8#[derive(Debug, Serialize, Clone)]
9#[serde(deny_unknown_fields)]
10#[serde(untagged)]
11pub enum EmptyOption<T> {
12    Some(T),
13    None {},
14}
15
16impl<T> Display for EmptyOption<T>
17where
18    T: Display,
19{
20    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
21        match self {
22            EmptyOption::Some(t) => write!(f, "{}", t),
23            EmptyOption::None {} => write!(f, ""),
24        }
25    }
26}
27
28impl<'de, T> Deserialize<'de> for EmptyOption<T>
29where
30    T: Deserialize<'de>,
31{
32    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
33    where
34        D: Deserializer<'de>,
35    {
36        Option::deserialize(deserializer).map(Into::into)
37    }
38}
39
40impl<T> From<EmptyOption<T>> for Option<T> {
41    fn from(empty_option: EmptyOption<T>) -> Option<T> {
42        match empty_option {
43            EmptyOption::Some(option) => Some(option),
44            EmptyOption::None {} => None,
45        }
46    }
47}
48
49impl<T> From<Option<T>> for EmptyOption<T> {
50    fn from(option: Option<T>) -> EmptyOption<T> {
51        match option {
52            Some(option) => EmptyOption::Some(option),
53            None {} => EmptyOption::None {},
54        }
55    }
56}
57
58impl<T> EmptyOption<T> {
59    fn into_option(self) -> Option<T> {
60        self.into()
61    }
62    fn as_option(&self) -> Option<&T> {
63        match self {
64            EmptyOption::Some(option) => Some(option),
65            EmptyOption::None {} => None,
66        }
67    }
68}
69
70#[derive(Serialize, Deserialize, Debug, Clone)]
71pub struct Project {
72        #[serde(rename(serialize = "id", deserialize = "$id"))]
73        pub id: String,
74        pub name: String,
75        pub description: String,
76        pub teamId: String,
77        pub logo: String,
78        pub url: String,
79        pub legalName: String,
80        pub legalCountry: String,
81        pub legalState: String,
82        pub legalCity: String,
83        pub legalAddress: String,
84        pub legalTaxId: String,
85        pub authLimit: i64,
86        pub platforms: Vec<Platform>,
87        pub webhooks: Vec<Webhook>,
88        pub keys: Vec<Key>,
89        pub domains: Vec<Domain>,
90        pub providerAmazonAppid: String,
91        pub providerAmazonSecret: String,
92        pub providerAppleAppid: String,
93        pub providerAppleSecret: String,
94        pub providerBitbucketAppid: String,
95        pub providerBitbucketSecret: String,
96        pub providerBitlyAppid: String,
97        pub providerBitlySecret: String,
98        pub providerBoxAppid: String,
99        pub providerBoxSecret: String,
100        pub providerDiscordAppid: String,
101        pub providerDiscordSecret: String,
102        pub providerDropboxAppid: String,
103        pub providerDropboxSecret: String,
104        pub providerFacebookAppid: String,
105        pub providerFacebookSecret: String,
106        pub providerGithubAppid: String,
107        pub providerGithubSecret: String,
108        pub providerGitlabAppid: String,
109        pub providerGitlabSecret: String,
110        pub providerGoogleAppid: String,
111        pub providerGoogleSecret: String,
112        pub providerLinkedinAppid: String,
113        pub providerLinkedinSecret: String,
114        pub providerMicrosoftAppid: String,
115        pub providerMicrosoftSecret: String,
116        pub providerNotionAppid: String,
117        pub providerNotionSecret: String,
118        pub providerPaypalAppid: String,
119        pub providerPaypalSecret: String,
120        pub providerPaypalSandboxAppid: String,
121        pub providerPaypalSandboxSecret: String,
122        pub providerSalesforceAppid: String,
123        pub providerSalesforceSecret: String,
124        pub providerSlackAppid: String,
125        pub providerSlackSecret: String,
126        pub providerSpotifyAppid: String,
127        pub providerSpotifySecret: String,
128        pub providerTradeshiftAppid: String,
129        pub providerTradeshiftSecret: String,
130        pub providerTradeshiftBoxAppid: String,
131        pub providerTradeshiftBoxSecret: String,
132        pub providerTwitchAppid: String,
133        pub providerTwitchSecret: String,
134        pub providerVkAppid: String,
135        pub providerVkSecret: String,
136        pub providerYahooAppid: String,
137        pub providerYahooSecret: String,
138        pub providerYammerAppid: String,
139        pub providerYammerSecret: String,
140        pub providerYandexAppid: String,
141        pub providerYandexSecret: String,
142        pub providerWordpressAppid: String,
143        pub providerWordpressSecret: String,
144        pub providerStripeAppid: String,
145        pub providerStripeSecret: String,
146        pub providerMockAppid: String,
147        pub providerMockSecret: String,
148        pub authEmailPassword: bool,
149        pub authUsersAuthMagicURL: bool,
150        pub authAnonymous: bool,
151        pub authInvites: bool,
152        pub authJWT: bool,
153        pub authPhone: bool,
154        pub serviceStatusForAccount: bool,
155        pub serviceStatusForAvatars: bool,
156        pub serviceStatusForDatabase: bool,
157        pub serviceStatusForLocale: bool,
158        pub serviceStatusForHealth: bool,
159        pub serviceStatusForStorage: bool,
160        pub serviceStatusForTeams: bool,
161        pub serviceStatusForUsers: bool,
162        pub serviceStatusForFunctions: bool,
163}
164
165impl Display for Project {
166    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
167        let mut formatBuffer = String::new();
168        formatBuffer.push_str(&format!("{:?}", self.id));
169        formatBuffer.push_str(&format!("{:?}", self.name));
170        formatBuffer.push_str(&format!("{:?}", self.description));
171        formatBuffer.push_str(&format!("{:?}", self.teamId));
172        formatBuffer.push_str(&format!("{:?}", self.logo));
173        formatBuffer.push_str(&format!("{:?}", self.url));
174        formatBuffer.push_str(&format!("{:?}", self.legalName));
175        formatBuffer.push_str(&format!("{:?}", self.legalCountry));
176        formatBuffer.push_str(&format!("{:?}", self.legalState));
177        formatBuffer.push_str(&format!("{:?}", self.legalCity));
178        formatBuffer.push_str(&format!("{:?}", self.legalAddress));
179        formatBuffer.push_str(&format!("{:?}", self.legalTaxId));
180        formatBuffer.push_str(&format!("{:?}", self.authLimit));
181        for item in &self.platforms {
182            formatBuffer.push_str(&format!("{:?}", item));
183        }
184        for item in &self.webhooks {
185            formatBuffer.push_str(&format!("{:?}", item));
186        }
187        for item in &self.keys {
188            formatBuffer.push_str(&format!("{:?}", item));
189        }
190        for item in &self.domains {
191            formatBuffer.push_str(&format!("{:?}", item));
192        }
193        formatBuffer.push_str(&format!("{:?}", self.providerAmazonAppid));
194        formatBuffer.push_str(&format!("{:?}", self.providerAmazonSecret));
195        formatBuffer.push_str(&format!("{:?}", self.providerAppleAppid));
196        formatBuffer.push_str(&format!("{:?}", self.providerAppleSecret));
197        formatBuffer.push_str(&format!("{:?}", self.providerBitbucketAppid));
198        formatBuffer.push_str(&format!("{:?}", self.providerBitbucketSecret));
199        formatBuffer.push_str(&format!("{:?}", self.providerBitlyAppid));
200        formatBuffer.push_str(&format!("{:?}", self.providerBitlySecret));
201        formatBuffer.push_str(&format!("{:?}", self.providerBoxAppid));
202        formatBuffer.push_str(&format!("{:?}", self.providerBoxSecret));
203        formatBuffer.push_str(&format!("{:?}", self.providerDiscordAppid));
204        formatBuffer.push_str(&format!("{:?}", self.providerDiscordSecret));
205        formatBuffer.push_str(&format!("{:?}", self.providerDropboxAppid));
206        formatBuffer.push_str(&format!("{:?}", self.providerDropboxSecret));
207        formatBuffer.push_str(&format!("{:?}", self.providerFacebookAppid));
208        formatBuffer.push_str(&format!("{:?}", self.providerFacebookSecret));
209        formatBuffer.push_str(&format!("{:?}", self.providerGithubAppid));
210        formatBuffer.push_str(&format!("{:?}", self.providerGithubSecret));
211        formatBuffer.push_str(&format!("{:?}", self.providerGitlabAppid));
212        formatBuffer.push_str(&format!("{:?}", self.providerGitlabSecret));
213        formatBuffer.push_str(&format!("{:?}", self.providerGoogleAppid));
214        formatBuffer.push_str(&format!("{:?}", self.providerGoogleSecret));
215        formatBuffer.push_str(&format!("{:?}", self.providerLinkedinAppid));
216        formatBuffer.push_str(&format!("{:?}", self.providerLinkedinSecret));
217        formatBuffer.push_str(&format!("{:?}", self.providerMicrosoftAppid));
218        formatBuffer.push_str(&format!("{:?}", self.providerMicrosoftSecret));
219        formatBuffer.push_str(&format!("{:?}", self.providerNotionAppid));
220        formatBuffer.push_str(&format!("{:?}", self.providerNotionSecret));
221        formatBuffer.push_str(&format!("{:?}", self.providerPaypalAppid));
222        formatBuffer.push_str(&format!("{:?}", self.providerPaypalSecret));
223        formatBuffer.push_str(&format!("{:?}", self.providerPaypalSandboxAppid));
224        formatBuffer.push_str(&format!("{:?}", self.providerPaypalSandboxSecret));
225        formatBuffer.push_str(&format!("{:?}", self.providerSalesforceAppid));
226        formatBuffer.push_str(&format!("{:?}", self.providerSalesforceSecret));
227        formatBuffer.push_str(&format!("{:?}", self.providerSlackAppid));
228        formatBuffer.push_str(&format!("{:?}", self.providerSlackSecret));
229        formatBuffer.push_str(&format!("{:?}", self.providerSpotifyAppid));
230        formatBuffer.push_str(&format!("{:?}", self.providerSpotifySecret));
231        formatBuffer.push_str(&format!("{:?}", self.providerTradeshiftAppid));
232        formatBuffer.push_str(&format!("{:?}", self.providerTradeshiftSecret));
233        formatBuffer.push_str(&format!("{:?}", self.providerTradeshiftBoxAppid));
234        formatBuffer.push_str(&format!("{:?}", self.providerTradeshiftBoxSecret));
235        formatBuffer.push_str(&format!("{:?}", self.providerTwitchAppid));
236        formatBuffer.push_str(&format!("{:?}", self.providerTwitchSecret));
237        formatBuffer.push_str(&format!("{:?}", self.providerVkAppid));
238        formatBuffer.push_str(&format!("{:?}", self.providerVkSecret));
239        formatBuffer.push_str(&format!("{:?}", self.providerYahooAppid));
240        formatBuffer.push_str(&format!("{:?}", self.providerYahooSecret));
241        formatBuffer.push_str(&format!("{:?}", self.providerYammerAppid));
242        formatBuffer.push_str(&format!("{:?}", self.providerYammerSecret));
243        formatBuffer.push_str(&format!("{:?}", self.providerYandexAppid));
244        formatBuffer.push_str(&format!("{:?}", self.providerYandexSecret));
245        formatBuffer.push_str(&format!("{:?}", self.providerWordpressAppid));
246        formatBuffer.push_str(&format!("{:?}", self.providerWordpressSecret));
247        formatBuffer.push_str(&format!("{:?}", self.providerStripeAppid));
248        formatBuffer.push_str(&format!("{:?}", self.providerStripeSecret));
249        formatBuffer.push_str(&format!("{:?}", self.providerMockAppid));
250        formatBuffer.push_str(&format!("{:?}", self.providerMockSecret));
251        formatBuffer.push_str(&format!("{:?}", self.authEmailPassword));
252        formatBuffer.push_str(&format!("{:?}", self.authUsersAuthMagicURL));
253        formatBuffer.push_str(&format!("{:?}", self.authAnonymous));
254        formatBuffer.push_str(&format!("{:?}", self.authInvites));
255        formatBuffer.push_str(&format!("{:?}", self.authJWT));
256        formatBuffer.push_str(&format!("{:?}", self.authPhone));
257        formatBuffer.push_str(&format!("{:?}", self.serviceStatusForAccount));
258        formatBuffer.push_str(&format!("{:?}", self.serviceStatusForAvatars));
259        formatBuffer.push_str(&format!("{:?}", self.serviceStatusForDatabase));
260        formatBuffer.push_str(&format!("{:?}", self.serviceStatusForLocale));
261        formatBuffer.push_str(&format!("{:?}", self.serviceStatusForHealth));
262        formatBuffer.push_str(&format!("{:?}", self.serviceStatusForStorage));
263        formatBuffer.push_str(&format!("{:?}", self.serviceStatusForTeams));
264        formatBuffer.push_str(&format!("{:?}", self.serviceStatusForUsers));
265        formatBuffer.push_str(&format!("{:?}", self.serviceStatusForFunctions));
266
267        write!(f, "{}", formatBuffer)
268    }
269}
270
271impl Project {
272    pub fn new(id: String, name: String, description: String, teamId: String, logo: String, url: String, legalName: String, legalCountry: String, legalState: String, legalCity: String, legalAddress: String, legalTaxId: String, authLimit: i64, platforms: Vec<Platform>, webhooks: Vec<Webhook>, keys: Vec<Key>, domains: Vec<Domain>, providerAmazonAppid: String, providerAmazonSecret: String, providerAppleAppid: String, providerAppleSecret: String, providerBitbucketAppid: String, providerBitbucketSecret: String, providerBitlyAppid: String, providerBitlySecret: String, providerBoxAppid: String, providerBoxSecret: String, providerDiscordAppid: String, providerDiscordSecret: String, providerDropboxAppid: String, providerDropboxSecret: String, providerFacebookAppid: String, providerFacebookSecret: String, providerGithubAppid: String, providerGithubSecret: String, providerGitlabAppid: String, providerGitlabSecret: String, providerGoogleAppid: String, providerGoogleSecret: String, providerLinkedinAppid: String, providerLinkedinSecret: String, providerMicrosoftAppid: String, providerMicrosoftSecret: String, providerNotionAppid: String, providerNotionSecret: String, providerPaypalAppid: String, providerPaypalSecret: String, providerPaypalSandboxAppid: String, providerPaypalSandboxSecret: String, providerSalesforceAppid: String, providerSalesforceSecret: String, providerSlackAppid: String, providerSlackSecret: String, providerSpotifyAppid: String, providerSpotifySecret: String, providerTradeshiftAppid: String, providerTradeshiftSecret: String, providerTradeshiftBoxAppid: String, providerTradeshiftBoxSecret: String, providerTwitchAppid: String, providerTwitchSecret: String, providerVkAppid: String, providerVkSecret: String, providerYahooAppid: String, providerYahooSecret: String, providerYammerAppid: String, providerYammerSecret: String, providerYandexAppid: String, providerYandexSecret: String, providerWordpressAppid: String, providerWordpressSecret: String, providerStripeAppid: String, providerStripeSecret: String, providerMockAppid: String, providerMockSecret: String, authEmailPassword: bool, authUsersAuthMagicURL: bool, authAnonymous: bool, authInvites: bool, authJWT: bool, authPhone: bool, serviceStatusForAccount: bool, serviceStatusForAvatars: bool, serviceStatusForDatabase: bool, serviceStatusForLocale: bool, serviceStatusForHealth: bool, serviceStatusForStorage: bool, serviceStatusForTeams: bool, serviceStatusForUsers: bool, serviceStatusForFunctions: bool, ) -> Self {
273        Self {
274            id: id,
275            name: name,
276            description: description,
277            teamId: teamId,
278            logo: logo,
279            url: url,
280            legalName: legalName,
281            legalCountry: legalCountry,
282            legalState: legalState,
283            legalCity: legalCity,
284            legalAddress: legalAddress,
285            legalTaxId: legalTaxId,
286            authLimit: authLimit,
287            platforms: platforms,
288            webhooks: webhooks,
289            keys: keys,
290            domains: domains,
291            providerAmazonAppid: providerAmazonAppid,
292            providerAmazonSecret: providerAmazonSecret,
293            providerAppleAppid: providerAppleAppid,
294            providerAppleSecret: providerAppleSecret,
295            providerBitbucketAppid: providerBitbucketAppid,
296            providerBitbucketSecret: providerBitbucketSecret,
297            providerBitlyAppid: providerBitlyAppid,
298            providerBitlySecret: providerBitlySecret,
299            providerBoxAppid: providerBoxAppid,
300            providerBoxSecret: providerBoxSecret,
301            providerDiscordAppid: providerDiscordAppid,
302            providerDiscordSecret: providerDiscordSecret,
303            providerDropboxAppid: providerDropboxAppid,
304            providerDropboxSecret: providerDropboxSecret,
305            providerFacebookAppid: providerFacebookAppid,
306            providerFacebookSecret: providerFacebookSecret,
307            providerGithubAppid: providerGithubAppid,
308            providerGithubSecret: providerGithubSecret,
309            providerGitlabAppid: providerGitlabAppid,
310            providerGitlabSecret: providerGitlabSecret,
311            providerGoogleAppid: providerGoogleAppid,
312            providerGoogleSecret: providerGoogleSecret,
313            providerLinkedinAppid: providerLinkedinAppid,
314            providerLinkedinSecret: providerLinkedinSecret,
315            providerMicrosoftAppid: providerMicrosoftAppid,
316            providerMicrosoftSecret: providerMicrosoftSecret,
317            providerNotionAppid: providerNotionAppid,
318            providerNotionSecret: providerNotionSecret,
319            providerPaypalAppid: providerPaypalAppid,
320            providerPaypalSecret: providerPaypalSecret,
321            providerPaypalSandboxAppid: providerPaypalSandboxAppid,
322            providerPaypalSandboxSecret: providerPaypalSandboxSecret,
323            providerSalesforceAppid: providerSalesforceAppid,
324            providerSalesforceSecret: providerSalesforceSecret,
325            providerSlackAppid: providerSlackAppid,
326            providerSlackSecret: providerSlackSecret,
327            providerSpotifyAppid: providerSpotifyAppid,
328            providerSpotifySecret: providerSpotifySecret,
329            providerTradeshiftAppid: providerTradeshiftAppid,
330            providerTradeshiftSecret: providerTradeshiftSecret,
331            providerTradeshiftBoxAppid: providerTradeshiftBoxAppid,
332            providerTradeshiftBoxSecret: providerTradeshiftBoxSecret,
333            providerTwitchAppid: providerTwitchAppid,
334            providerTwitchSecret: providerTwitchSecret,
335            providerVkAppid: providerVkAppid,
336            providerVkSecret: providerVkSecret,
337            providerYahooAppid: providerYahooAppid,
338            providerYahooSecret: providerYahooSecret,
339            providerYammerAppid: providerYammerAppid,
340            providerYammerSecret: providerYammerSecret,
341            providerYandexAppid: providerYandexAppid,
342            providerYandexSecret: providerYandexSecret,
343            providerWordpressAppid: providerWordpressAppid,
344            providerWordpressSecret: providerWordpressSecret,
345            providerStripeAppid: providerStripeAppid,
346            providerStripeSecret: providerStripeSecret,
347            providerMockAppid: providerMockAppid,
348            providerMockSecret: providerMockSecret,
349            authEmailPassword: authEmailPassword,
350            authUsersAuthMagicURL: authUsersAuthMagicURL,
351            authAnonymous: authAnonymous,
352            authInvites: authInvites,
353            authJWT: authJWT,
354            authPhone: authPhone,
355            serviceStatusForAccount: serviceStatusForAccount,
356            serviceStatusForAvatars: serviceStatusForAvatars,
357            serviceStatusForDatabase: serviceStatusForDatabase,
358            serviceStatusForLocale: serviceStatusForLocale,
359            serviceStatusForHealth: serviceStatusForHealth,
360            serviceStatusForStorage: serviceStatusForStorage,
361            serviceStatusForTeams: serviceStatusForTeams,
362            serviceStatusForUsers: serviceStatusForUsers,
363            serviceStatusForFunctions: serviceStatusForFunctions,
364            }
365    }
366}