2016-06-07 20:05:27 -04:00
|
|
|
|
using System;
|
2017-03-08 21:45:08 -05:00
|
|
|
|
using Bit.Core.Models.Table;
|
2017-03-18 11:58:02 -04:00
|
|
|
|
using Core.Models.Data;
|
2016-06-07 20:05:27 -04:00
|
|
|
|
|
2017-03-08 21:55:08 -05:00
|
|
|
|
namespace Bit.Core.Models.Api
|
2016-06-07 20:05:27 -04:00
|
|
|
|
{
|
|
|
|
|
|
public class CipherResponseModel : ResponseModel
|
|
|
|
|
|
{
|
2017-03-18 11:58:02 -04:00
|
|
|
|
public CipherResponseModel(Cipher cipher, string obj = "cipher")
|
2017-02-21 22:52:02 -05:00
|
|
|
|
: base(obj)
|
2016-06-07 20:05:27 -04:00
|
|
|
|
{
|
|
|
|
|
|
if(cipher == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(cipher));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Id = cipher.Id.ToString();
|
|
|
|
|
|
Type = cipher.Type;
|
|
|
|
|
|
RevisionDate = cipher.RevisionDate;
|
2016-06-08 22:00:31 -04:00
|
|
|
|
|
|
|
|
|
|
switch(cipher.Type)
|
|
|
|
|
|
{
|
2017-03-18 11:58:02 -04:00
|
|
|
|
case Enums.CipherType.Login:
|
|
|
|
|
|
Data = new LoginDataModel(cipher);
|
2016-06-08 22:00:31 -04:00
|
|
|
|
break;
|
2017-03-18 11:58:02 -04:00
|
|
|
|
default:
|
|
|
|
|
|
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public CipherResponseModel(CipherDetails cipher, string obj = "cipher")
|
|
|
|
|
|
: base(obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(cipher == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(cipher));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Id = cipher.Id.ToString();
|
|
|
|
|
|
Type = cipher.Type;
|
|
|
|
|
|
RevisionDate = cipher.RevisionDate;
|
|
|
|
|
|
|
|
|
|
|
|
switch(cipher.Type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Enums.CipherType.Login:
|
2017-01-02 21:52:13 -05:00
|
|
|
|
Data = new LoginDataModel(cipher);
|
2016-06-08 22:00:31 -04:00
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
|
|
|
|
|
}
|
2016-06-07 20:05:27 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
public string FolderId { get; set; }
|
2017-03-18 11:58:02 -04:00
|
|
|
|
public Enums.CipherType Type { get; set; }
|
2016-06-08 22:19:08 -04:00
|
|
|
|
public bool Favorite { get; set; }
|
2016-06-08 22:00:31 -04:00
|
|
|
|
public dynamic Data { get; set; }
|
|
|
|
|
|
public DateTime RevisionDate { get; set; }
|
2016-06-07 20:05:27 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|