|
| 1 | +use crate::sync::gws::RUST_LANG_GWS_DOMAIN; |
| 2 | +use async_trait::async_trait; |
| 3 | +use rust_team_data::v1::GoogleWorkspace; |
| 4 | + |
| 5 | +/// https://developers.google.com/workspace/admin/directory/reference/rest/v1/groups |
| 6 | +#[derive(Clone, Debug, PartialEq)] |
| 7 | +pub(crate) struct Group { |
| 8 | + pub name: String, |
| 9 | + pub email: String, |
| 10 | +} |
| 11 | + |
| 12 | +/// https://developers.google.com/workspace/admin/directory/reference/rest/v1/users#UserName |
| 13 | +#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] |
| 14 | +pub(crate) struct UserName { |
| 15 | + pub given_name: String, |
| 16 | + pub family_name: String, |
| 17 | +} |
| 18 | + |
| 19 | +///https://developers.google.com/workspace/admin/directory/reference/rest/v1/users |
| 20 | +#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] |
| 21 | +pub(crate) struct User { |
| 22 | + pub name: UserName, |
| 23 | + pub primary_email: String, |
| 24 | +} |
| 25 | + |
| 26 | +impl From<&GoogleWorkspace> for User { |
| 27 | + fn from(gws: &GoogleWorkspace) -> Self { |
| 28 | + Self { |
| 29 | + primary_email: format!("{}@{}", gws.account_handle, RUST_LANG_GWS_DOMAIN), |
| 30 | + name: UserName { |
| 31 | + given_name: gws.first_name.to_string(), |
| 32 | + family_name: gws.last_name.to_string(), |
| 33 | + }, |
| 34 | + } |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +#[async_trait] |
| 39 | +pub(crate) trait GoogleWorkspaceApiClient { |
| 40 | + async fn get_users(&self) -> anyhow::Result<Vec<User>>; |
| 41 | +} |
0 commit comments