Files
server/src/Core/Models/Api/Response/OrganizationUserResponseModel.cs

84 lines
2.9 KiB
C#
Raw Normal View History

2017-03-04 21:28:41 -05:00
using System;
using Bit.Core.Enums;
using Bit.Core.Models.Data;
2017-03-11 15:34:57 -05:00
using System.Collections.Generic;
using System.Linq;
using Bit.Core.Models.Table;
2017-03-04 21:28:41 -05:00
2017-03-08 21:55:08 -05:00
namespace Bit.Core.Models.Api
2017-03-04 21:28:41 -05:00
{
public class OrganizationUserResponseModel : ResponseModel
{
public OrganizationUserResponseModel(OrganizationUser organizationUser, string obj = "organizationUser")
: base(obj)
{
if (organizationUser == null)
{
throw new ArgumentNullException(nameof(organizationUser));
}
Id = organizationUser.Id.ToString();
UserId = organizationUser.UserId?.ToString();
Type = organizationUser.Type;
Status = organizationUser.Status;
AccessAll = organizationUser.AccessAll;
}
2017-03-06 20:51:13 -05:00
public OrganizationUserResponseModel(OrganizationUserUserDetails organizationUser, string obj = "organizationUser")
2017-03-04 21:28:41 -05:00
: base(obj)
{
if (organizationUser == null)
2017-03-04 21:28:41 -05:00
{
throw new ArgumentNullException(nameof(organizationUser));
}
Id = organizationUser.Id.ToString();
UserId = organizationUser.UserId?.ToString();
Type = organizationUser.Type;
Status = organizationUser.Status;
AccessAll = organizationUser.AccessAll;
2017-03-04 21:28:41 -05:00
}
public string Id { get; set; }
public string UserId { get; set; }
public OrganizationUserType Type { get; set; }
public OrganizationUserStatusType Status { get; set; }
public bool AccessAll { get; set; }
2017-03-04 21:28:41 -05:00
}
2017-03-11 15:34:57 -05:00
public class OrganizationUserDetailsResponseModel : OrganizationUserResponseModel
{
public OrganizationUserDetailsResponseModel(OrganizationUser organizationUser,
IEnumerable<SelectionReadOnly> collections)
2017-03-11 15:34:57 -05:00
: base(organizationUser, "organizationUserDetails")
{
Collections = collections.Select(c => new SelectionReadOnlyResponseModel(c));
2017-03-11 15:34:57 -05:00
}
public IEnumerable<SelectionReadOnlyResponseModel> Collections { get; set; }
}
public class OrganizationUserUserDetailsResponseModel : OrganizationUserResponseModel
{
public OrganizationUserUserDetailsResponseModel(OrganizationUserUserDetails organizationUser,
bool twoFactorEnabled, string obj = "organizationUserUserDetails")
: base(organizationUser, obj)
{
if (organizationUser == null)
{
throw new ArgumentNullException(nameof(organizationUser));
}
Name = organizationUser.Name;
Email = organizationUser.Email;
TwoFactorEnabled = twoFactorEnabled;
SsoBound = !string.IsNullOrWhiteSpace(organizationUser.SsoExternalId);
}
public string Name { get; set; }
public string Email { get; set; }
public bool TwoFactorEnabled { get; set; }
public bool SsoBound { get; set; }
2017-03-11 15:34:57 -05:00
}
2017-03-04 21:28:41 -05:00
}