aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-04-19 06:28:19 -0400
committerJesse Luehrs <doy@tozt.net>2020-04-19 06:28:19 -0400
commit769f0fddf89fff7c026d70857cb0e7c4fa55d759 (patch)
treee217098ff02cee82cd2459b8a426461cc723c139
parentd61ba750f305269c260d415a8e79c32292b3c703 (diff)
downloadrbw-769f0fddf89fff7c026d70857cb0e7c4fa55d759.tar.gz
rbw-769f0fddf89fff7c026d70857cb0e7c4fa55d759.zip
clean up api model structs
-rw-r--r--src/api.rs173
1 files changed, 61 insertions, 112 deletions
diff --git a/src/api.rs b/src/api.rs
index efceda8..89da6d7 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -30,13 +30,6 @@ struct ConnectPasswordReq {
device_push_token: String,
}
-#[derive(serde::Serialize, Debug)]
-struct ConnectRefreshTokenReq {
- grant_type: String,
- client_id: String,
- refresh_token: String,
-}
-
#[derive(serde::Deserialize, Debug)]
struct ConnectPasswordRes {
access_token: String,
@@ -59,6 +52,13 @@ struct ConnectErrorResErrorModel {
message: String,
}
+#[derive(serde::Serialize, Debug)]
+struct ConnectRefreshTokenReq {
+ grant_type: String,
+ client_id: String,
+ refresh_token: String,
+}
+
#[derive(serde::Deserialize, Debug)]
struct ConnectRefreshTokenRes {
access_token: String,
@@ -74,111 +74,7 @@ struct SyncRes {
#[serde(rename = "Ciphers")]
ciphers: Vec<SyncResCipher>,
#[serde(rename = "Profile")]
- profile: Profile,
-}
-
-#[derive(serde::Serialize, Debug)]
-struct CiphersPostReq {
- #[serde(rename = "type")]
- ty: u32, // XXX what are the valid types?
- #[serde(rename = "folderId")]
- folder_id: Option<String>,
- #[serde(rename = "organizationId")]
- organization_id: Option<String>,
- name: String,
- notes: Option<String>,
- favorite: bool,
- login: CiphersPostReqLogin,
-}
-
-#[derive(serde::Serialize, Debug)]
-struct CiphersPostReqLogin {
- uri: Option<String>,
- username: Option<String>,
- password: Option<String>,
- totp: Option<String>,
-}
-
-#[derive(serde::Serialize, Debug)]
-struct CiphersPutReq {
- #[serde(rename = "type")]
- ty: u32, // XXX what are the valid types?
- name: String,
- notes: Option<String>,
- login: CiphersPutReqLogin,
- #[serde(rename = "passwordHistory")]
- password_history: Vec<CiphersPutReqHistory>,
-}
-
-#[derive(serde::Serialize, Debug)]
-struct CiphersPutReqLogin {
- username: Option<String>,
- password: Option<String>,
-}
-
-#[derive(serde::Serialize, Debug)]
-struct CiphersPutReqHistory {
- #[serde(rename = "LastUsedDate")]
- last_used_date: String,
- #[serde(rename = "Password")]
- password: String,
-}
-
-#[derive(serde::Deserialize, Debug)]
-struct CiphersRes {
- #[serde(rename = "FolderId")]
- folder_id: Option<String>,
- #[serde(rename = "Favorite")]
- favorite: bool,
- #[serde(rename = "Edit")]
- edit: bool,
- #[serde(rename = "Id")]
- id: String,
- #[serde(rename = "OrganizationId")]
- organization_id: String,
- #[serde(rename = "Type")]
- ty: u32,
- #[serde(rename = "Login")]
- login: CiphersResLogin,
- #[serde(rename = "Username")]
- username: Option<String>,
- #[serde(rename = "Password")]
- password: Option<String>,
- #[serde(rename = "Totp")]
- totp: Option<String>,
- #[serde(rename = "Name")]
- name: String,
- #[serde(rename = "Notes")]
- notes: Option<String>,
- #[serde(rename = "Fields")]
- fields: Option<()>, // XXX what type is this?
- #[serde(rename = "Attachments")]
- attachments: Option<()>, // XXX what type is this?
- #[serde(rename = "OrganizationUseTotp")]
- organization_use_totp: bool,
- #[serde(rename = "RevisionDate")]
- revision_date: String,
- #[serde(rename = "Object")]
- object: String,
-}
-
-#[derive(serde::Deserialize, Debug)]
-struct CiphersResLogin {
- uris: Vec<CiphersResLoginUri>,
-}
-
-#[derive(serde::Deserialize, Debug)]
-struct CiphersResLoginUri {
- #[serde(rename = "Uri")]
- uri: String,
- #[serde(rename = "Match")]
- mtch: Option<()>, // XXX what type is this?
-}
-
-#[derive(serde::Deserialize, Debug)]
-struct Profile {
- #[serde(rename = "Key")]
- key: String,
+ profile: SyncResProfile,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
@@ -219,6 +115,12 @@ impl SyncResCipher {
}
}
+#[derive(serde::Deserialize, Debug)]
+struct SyncResProfile {
+ #[serde(rename = "Key")]
+ key: String,
+}
+
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
struct SyncResLogin {
#[serde(rename = "Username")]
@@ -235,6 +137,53 @@ struct SyncResPasswordHistory {
password: String,
}
+#[derive(serde::Serialize, Debug)]
+struct CiphersPostReq {
+ #[serde(rename = "type")]
+ ty: u32, // XXX what are the valid types?
+ #[serde(rename = "folderId")]
+ folder_id: Option<String>,
+ #[serde(rename = "organizationId")]
+ organization_id: Option<String>,
+ name: String,
+ notes: Option<String>,
+ favorite: bool,
+ login: CiphersPostReqLogin,
+}
+
+#[derive(serde::Serialize, Debug)]
+struct CiphersPostReqLogin {
+ uri: Option<String>,
+ username: Option<String>,
+ password: Option<String>,
+ totp: Option<String>,
+}
+
+#[derive(serde::Serialize, Debug)]
+struct CiphersPutReq {
+ #[serde(rename = "type")]
+ ty: u32, // XXX what are the valid types?
+ name: String,
+ notes: Option<String>,
+ login: CiphersPutReqLogin,
+ #[serde(rename = "passwordHistory")]
+ password_history: Vec<CiphersPutReqHistory>,
+}
+
+#[derive(serde::Serialize, Debug)]
+struct CiphersPutReqLogin {
+ username: Option<String>,
+ password: Option<String>,
+}
+
+#[derive(serde::Serialize, Debug)]
+struct CiphersPutReqHistory {
+ #[serde(rename = "LastUsedDate")]
+ last_used_date: String,
+ #[serde(rename = "Password")]
+ password: String,
+}
+
#[derive(Debug)]
pub struct Client {
base_url: String,