Bit.Api.Models.CipherRequestModel.ToCipher C# (CSharp) Method

ToCipher() public method

public ToCipher ( string userId = null ) : Cipher
userId string
return Cipher
        public virtual Cipher ToCipher(string userId = null)
        {
            var cipher = new Cipher
            {
                Id = new Guid(Id),
                UserId = new Guid(userId),
                FolderId = string.IsNullOrWhiteSpace(FolderId) ? null : (Guid?)new Guid(FolderId),
                Type = Type
            };

            switch(Type)
            {
                case CipherType.Folder:
                    cipher.Data = JsonConvert.SerializeObject(new FolderDataModel(this), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
                    break;
                case CipherType.Site:
                    cipher.Data = JsonConvert.SerializeObject(new SiteDataModel(this), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
                    break;
                default:
                    throw new ArgumentException("Unsupported " + nameof(Type) + ".");
            }

            return cipher;
        }
CipherRequestModel