Skip to content

Commit

Permalink
made user types public
Browse files Browse the repository at this point in the history
Signed-off-by: Ankur Srivastava <[email protected]>
  • Loading branch information
ansrivas committed Apr 18, 2020
1 parent e209af3 commit 06cd75d
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
clippy:
name: Clippy
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
153 changes: 3 additions & 150 deletions src/user/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,156 +27,9 @@ use crate::{
response::APIResponse,
};

use serde::{Deserialize, Serialize};
use crate::user::types::*;
use serde::Serialize;
use std::collections::HashMap;
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct UserAuth {
pub state: String,
pub token: String,
pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResUserPasswordChange {
// pub message: Option<String>,
pub token: String,
// pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResCompleteOTPConfig {
// pub message: Option<String>,
pub token: String,
pub method: String,
// pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResConfigure2fa {
// pub message: Option<String>,
pub qrcode: String,
pub uri: String,
pub method: String,
// pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResConfirmUseremailAddress {
// pub message: Option<String>,
pub invite_details: UserEmail,
// pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResConfirmPasswordReset {
// pub message: Option<String>,
pub invite_details: UserEmail,
// pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct UserEmail {
pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct UserAuthLoginOptions {
pub action: String,
pub method: Option<String>,
pub name: Option<String>,
pub redirect_url: Option<String>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct UserInfo {
pub user: User,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Invitation {
pub invite_code: String,
pub invite_time: String,
pub inviting_user_email: String,
pub project_name: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct User {
pub auth: Vec<String>,
pub create_time: String,
pub features: Option<HashMap<String, String>>,
pub intercom: Option<HashMap<String, String>>,
pub invitations: Vec<Invitation>,
pub project_membership: HashMap<String, String>,
pub projects: Vec<String>,
pub real_name: String,
pub state: String,
pub token_validity_begin: String,
pub user: String,
pub user_id: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct AccessToken {
pub create_time: String,
pub created_manually: bool,
pub currently_active: bool,
pub description: Option<String>,
pub expiry_time: Option<String>,
pub extend_when_used: bool,
pub full_token: Option<String>,
pub last_ip: Option<String>,
pub last_used_time: Option<String>,
pub last_user_agent: Option<String>,
pub last_user_agent_human_readable: Option<String>,
pub max_age_seconds: Option<i64>,
pub token_prefix: Option<String>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct AccessTokens {
pub tokens: Vec<AccessToken>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct AuthenticationMethod {
pub authentication_method_account_id: String,
pub create_time: String,
pub currently_active: bool,
pub delete_time: String,
pub last_used_time: String,
pub method_id: String,
pub name: String,
pub public_remote_identity: String,
pub remote_provider_id: String,
pub state: String,
pub update_time: String,
pub user_email: String,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct AuthenticationMethods {
pub authentication_methods: Vec<AuthenticationMethod>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResUserCreate {
pub state: String,
pub token: String,
pub user: User,
pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct UserCreateConfig {
pub credit_code: String,
pub email: String,
pub email_communication_categories: Vec<String>,
pub origin: String,
pub password: String,
pub real_name: String,
pub token: String,
}

pub struct UserApi {
http_client: HTTPClient,
}
Expand Down Expand Up @@ -365,7 +218,7 @@ impl UserApi {
///
/// ```rust,no_run
/// use std::collections::HashMap;
/// use aiven_rs::user::UserCreateConfig;
/// use aiven_rs::user::types::UserCreateConfig;
/// #[tokio::main]
/// async fn main()-> Result<(), Box<dyn std::error::Error>>{
/// let client = aiven_rs::AivenClient::new("https://api.aiven.io", "v1");
Expand Down
6 changes: 2 additions & 4 deletions src/user/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mod api;
pub use api::{
Invitation, ResUserPasswordChange, User, UserApi, UserAuth, UserAuthLoginOptions,
UserCreateConfig, UserInfo,
};
pub use api::UserApi;
pub mod types;
171 changes: 171 additions & 0 deletions src/user/types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
// MIT License
//
// Copyright (c) 2020 Ankur Srivastava
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct UserAuth {
pub state: String,
pub token: String,
pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResUserPasswordChange {
// pub message: Option<String>,
pub token: String,
// pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResCompleteOTPConfig {
// pub message: Option<String>,
pub token: String,
pub method: String,
// pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResConfigure2fa {
// pub message: Option<String>,
pub qrcode: String,
pub uri: String,
pub method: String,
// pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResConfirmUseremailAddress {
// pub message: Option<String>,
pub invite_details: UserEmail,
// pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResConfirmPasswordReset {
// pub message: Option<String>,
pub invite_details: UserEmail,
// pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct UserEmail {
pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct UserAuthLoginOptions {
pub action: String,
pub method: Option<String>,
pub name: Option<String>,
pub redirect_url: Option<String>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct UserInfo {
pub user: User,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Invitation {
pub invite_code: String,
pub invite_time: String,
pub inviting_user_email: String,
pub project_name: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct User {
pub auth: Vec<String>,
pub create_time: String,
pub features: Option<HashMap<String, String>>,
pub intercom: Option<HashMap<String, String>>,
pub invitations: Vec<Invitation>,
pub project_membership: HashMap<String, String>,
pub projects: Vec<String>,
pub real_name: String,
pub state: String,
pub token_validity_begin: String,
pub user: String,
pub user_id: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct AccessToken {
pub create_time: String,
pub created_manually: bool,
pub currently_active: bool,
pub description: Option<String>,
pub expiry_time: Option<String>,
pub extend_when_used: bool,
pub full_token: Option<String>,
pub last_ip: Option<String>,
pub last_used_time: Option<String>,
pub last_user_agent: Option<String>,
pub last_user_agent_human_readable: Option<String>,
pub max_age_seconds: Option<i64>,
pub token_prefix: Option<String>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct AccessTokens {
pub tokens: Vec<AccessToken>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct AuthenticationMethod {
pub authentication_method_account_id: String,
pub create_time: String,
pub currently_active: bool,
pub delete_time: String,
pub last_used_time: String,
pub method_id: String,
pub name: String,
pub public_remote_identity: String,
pub remote_provider_id: String,
pub state: String,
pub update_time: String,
pub user_email: String,
}
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct AuthenticationMethods {
pub authentication_methods: Vec<AuthenticationMethod>,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ResUserCreate {
pub state: String,
pub token: String,
pub user: User,
pub user_email: String,
}

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct UserCreateConfig {
pub credit_code: String,
pub email: String,
pub email_communication_categories: Vec<String>,
pub origin: String,
pub password: String,
pub real_name: String,
pub token: String,
}

0 comments on commit 06cd75d

Please sign in to comment.