mirror of
https://github.com/bitwarden/server
synced 2025-12-23 03:33:35 +00:00
Move request/response models (#1754)
This commit is contained in:
55
src/Api/Models/Response/CollectionResponseModel.cs
Normal file
55
src/Api/Models/Response/CollectionResponseModel.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
|
||||
namespace Bit.Api.Models.Response
|
||||
{
|
||||
public class CollectionResponseModel : ResponseModel
|
||||
{
|
||||
public CollectionResponseModel(Collection collection, string obj = "collection")
|
||||
: base(obj)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(collection));
|
||||
}
|
||||
|
||||
Id = collection.Id.ToString();
|
||||
OrganizationId = collection.OrganizationId.ToString();
|
||||
Name = collection.Name;
|
||||
ExternalId = collection.ExternalId;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ExternalId { get; set; }
|
||||
}
|
||||
|
||||
public class CollectionDetailsResponseModel : CollectionResponseModel
|
||||
{
|
||||
public CollectionDetailsResponseModel(CollectionDetails collectionDetails)
|
||||
: base(collectionDetails, "collectionDetails")
|
||||
{
|
||||
ReadOnly = collectionDetails.ReadOnly;
|
||||
HidePasswords = collectionDetails.HidePasswords;
|
||||
}
|
||||
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
}
|
||||
|
||||
public class CollectionGroupDetailsResponseModel : CollectionResponseModel
|
||||
{
|
||||
public CollectionGroupDetailsResponseModel(Collection collection, IEnumerable<SelectionReadOnly> groups)
|
||||
: base(collection, "collectionGroupDetails")
|
||||
{
|
||||
Groups = groups.Select(g => new SelectionReadOnlyResponseModel(g));
|
||||
}
|
||||
|
||||
public IEnumerable<SelectionReadOnlyResponseModel> Groups { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user