Commit 64459cbc authored by Ben Boeckel's avatar Ben Boeckel
Browse files

types: update for UserFull's rename upstream

parent f5fd77d5
......@@ -96,13 +96,13 @@ impl Gitlab {
};
// Ensure the API is working.
let _: UserFull = try!(api._get("user"));
let _: UserPublic = try!(api._get("user"));
Ok(api)
}
/// The user the API is acting as.
pub fn current_user(&self) -> Result<UserFull> {
pub fn current_user(&self) -> Result<UserPublic> {
self._get("user")
}
......
......@@ -488,43 +488,43 @@ fn test_read_user() {
}
#[test]
fn test_read_user_full() {
let user_full: UserFull = read_test_file("user_full");
assert_eq!(user_full.username, "ben.boeckel");
assert_eq!(user_full.name, "Ben Boeckel");
assert_eq!(user_full.id, UserId::new(13));
assert_eq!(user_full.state, UserState::Active);
assert_eq!(user_full.avatar_url,
fn test_read_user_public() {
let user_public: UserPublic = read_test_file("user_public");
assert_eq!(user_public.username, "ben.boeckel");
assert_eq!(user_public.name, "Ben Boeckel");
assert_eq!(user_public.id, UserId::new(13));
assert_eq!(user_public.state, UserState::Active);
assert_eq!(user_public.avatar_url,
"https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon");
assert_eq!(user_full.web_url, "https://gitlab.kitware.com/ben.boeckel");
assert_eq!(user_full.created_at,
assert_eq!(user_public.web_url, "https://gitlab.kitware.com/ben.boeckel");
assert_eq!(user_public.created_at,
UTC.ymd(2015, 2, 26)
.and_hms_milli(17, 23, 28, 730));
assert_eq!(user_full.is_admin, false);
assert_eq!(user_full.bio, None);
assert_eq!(user_full.location, None);
assert_eq!(user_full.skype, "");
assert_eq!(user_full.linkedin, "");
assert_eq!(user_full.twitter, "");
assert_eq!(user_full.website_url, "");
assert_eq!(user_full.organization, None);
assert_eq!(user_full.last_sign_in_at,
assert_eq!(user_public.is_admin, false);
assert_eq!(user_public.bio, None);
assert_eq!(user_public.location, None);
assert_eq!(user_public.skype, "");
assert_eq!(user_public.linkedin, "");
assert_eq!(user_public.twitter, "");
assert_eq!(user_public.website_url, "");
assert_eq!(user_public.organization, None);
assert_eq!(user_public.last_sign_in_at,
Some(UTC.ymd(2016, 12, 7)
.and_hms_milli(15, 5, 56, 167)));
assert_eq!(user_full.confirmed_at,
assert_eq!(user_public.confirmed_at,
UTC.ymd(2015, 2, 26)
.and_hms_milli(17, 23, 28, 693));
assert_eq!(user_full.email, "ben.boeckel@kitware.com");
assert_eq!(user_full.theme_id, ThemeId::new(2));
assert_eq!(user_full.color_scheme_id, ColorSchemeId::new(2));
assert_eq!(user_full.projects_limit, 50);
assert_eq!(user_full.current_sign_in_at,
assert_eq!(user_public.email, "ben.boeckel@kitware.com");
assert_eq!(user_public.theme_id, ThemeId::new(2));
assert_eq!(user_public.color_scheme_id, ColorSchemeId::new(2));
assert_eq!(user_public.projects_limit, 50);
assert_eq!(user_public.current_sign_in_at,
Some(UTC.ymd(2016, 12, 7)
.and_hms_milli(16, 15, 50, 720)));
assert!(user_full.identities.is_empty());
assert_eq!(user_full.can_create_group, true);
assert_eq!(user_full.can_create_project, true);
assert_eq!(user_full.two_factor_enabled, true);
assert_eq!(user_full.external, false);
assert!(user_public.identities.is_empty());
assert_eq!(user_public.can_create_group, true);
assert_eq!(user_public.can_create_project, true);
assert_eq!(user_public.two_factor_enabled, true);
assert_eq!(user_public.external, false);
}
......@@ -141,7 +141,7 @@ impl_id!(ColorSchemeId);
#[derive(Serialize, Deserialize, Debug, Clone)]
/// Full user structure information.
pub struct UserFull {
pub struct UserPublic {
/// The username.
pub username: String,
/// The display name.
......@@ -201,14 +201,10 @@ pub struct UserFull {
pub two_factor_enabled: bool,
/// Whether the account is externally controlled.
pub external: bool,
// There's a `UserLogin` structure as well which contains this key too, but the API already has
// this token, so this is being skipped.
//pub private_token: String,
}
impl From<UserFull> for UserBasic {
fn from(user: UserFull) -> Self {
impl From<UserPublic> for UserBasic {
fn from(user: UserPublic) -> Self {
UserBasic {
username: user.username,
name: user.name,
......@@ -220,8 +216,8 @@ impl From<UserFull> for UserBasic {
}
}
impl From<UserFull> for User {
fn from(user: UserFull) -> Self {
impl From<UserPublic> for User {
fn from(user: UserPublic) -> Self {
User {
username: user.username,
name: user.name,
......@@ -724,6 +720,8 @@ pub struct GroupDetail {
pub shared_projects: Vec<Project>,
/// Whether membership requests are allowed for the group.
pub request_access_enabled: bool,
/// Statistics about the group.
pub statistics: Option<ProjectStatistics>,
}
impl From<GroupDetail> for Group {
......@@ -738,6 +736,7 @@ impl From<GroupDetail> for Group {
avatar_url: detail.avatar_url,
web_url: detail.web_url,
request_access_enabled: detail.request_access_enabled,
statistics: detail.statistics,
}
}
}
......@@ -1323,7 +1322,7 @@ pub struct SshKeyWithUser {
/// When the key was created.
pub created_at: DateTime<UTC>,
/// The user associated with the SSH key.
pub user: UserFull,
pub user: UserPublic,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment