openapi_github/models/
authorization.rs

1/*
2 * GitHub's official OpenAPI spec + Octokit extension
3 *
4 * OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs
5 *
6 * The version of the OpenAPI document: 16.6.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// Authorization : The authorization for an OAuth app, GitHub App, or a Personal Access Token.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Authorization {
17    #[serde(rename = "id")]
18    pub id: i32,
19    #[serde(rename = "url")]
20    pub url: String,
21    /// A list of scopes that this authorization is in.
22    #[serde(rename = "scopes", deserialize_with = "Option::deserialize")]
23    pub scopes: Option<Vec<String>>,
24    #[serde(rename = "token")]
25    pub token: String,
26    #[serde(rename = "token_last_eight", deserialize_with = "Option::deserialize")]
27    pub token_last_eight: Option<String>,
28    #[serde(rename = "hashed_token", deserialize_with = "Option::deserialize")]
29    pub hashed_token: Option<String>,
30    #[serde(rename = "app")]
31    pub app: Box<models::AuthorizationApp>,
32    #[serde(rename = "note", deserialize_with = "Option::deserialize")]
33    pub note: Option<String>,
34    #[serde(rename = "note_url", deserialize_with = "Option::deserialize")]
35    pub note_url: Option<String>,
36    #[serde(rename = "updated_at")]
37    pub updated_at: String,
38    #[serde(rename = "created_at")]
39    pub created_at: String,
40    #[serde(rename = "fingerprint", deserialize_with = "Option::deserialize")]
41    pub fingerprint: Option<String>,
42    #[serde(rename = "user", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
43    pub user: Option<Option<Box<models::NullableSimpleUser>>>,
44    #[serde(rename = "installation", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
45    pub installation: Option<Option<Box<models::NullableScopedInstallation>>>,
46    #[serde(rename = "expires_at", deserialize_with = "Option::deserialize")]
47    pub expires_at: Option<String>,
48}
49
50impl Authorization {
51    /// The authorization for an OAuth app, GitHub App, or a Personal Access Token.
52    pub fn new(id: i32, url: String, scopes: Option<Vec<String>>, token: String, token_last_eight: Option<String>, hashed_token: Option<String>, app: models::AuthorizationApp, note: Option<String>, note_url: Option<String>, updated_at: String, created_at: String, fingerprint: Option<String>, expires_at: Option<String>) -> Authorization {
53        Authorization {
54            id,
55            url,
56            scopes,
57            token,
58            token_last_eight,
59            hashed_token,
60            app: Box::new(app),
61            note,
62            note_url,
63            updated_at,
64            created_at,
65            fingerprint,
66            user: None,
67            installation: None,
68            expires_at,
69        }
70    }
71}
72