1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 17:12:49 -05:00

device apis and models

This commit is contained in:
Kyle Spearrin
2016-06-18 16:03:33 -04:00
parent 25793e0523
commit 4fd65f974d
3 changed files with 152 additions and 0 deletions

View File

@ -0,0 +1,36 @@
using System;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Domains;
using Bit.Core.Enums;
using Newtonsoft.Json;
namespace Bit.Api.Models
{
public class DeviceRequestModel
{
[Required]
public DeviceType? Type { get; set; }
[Required]
[StringLength(50)]
public string Name { get; set; }
[StringLength(255)]
public string PushToken { get; set; }
public Device ToDevice(string userId = null)
{
return ToDevice(new Device
{
UserId = new Guid(userId)
});
}
public Device ToDevice(Device existingDevice)
{
existingDevice.Name = Name;
existingDevice.PushToken = PushToken;
existingDevice.Type = Type.Value;
return existingDevice;
}
}
}