Ejemplo n.º 1
0
        public CipherResponseModel(Cipher cipher)
            : base("cipher")
        {
            if(cipher == null)
            {
                throw new ArgumentNullException(nameof(cipher));
            }

            Id = cipher.Id.ToString();
            FolderId = cipher.FolderId?.ToString();
            Type = cipher.Type;
            Favorite = cipher.Favorite;
            RevisionDate = cipher.RevisionDate;

            switch(cipher.Type)
            {
                case Core.Enums.CipherType.Folder:
                    Data = new FolderDataModel(cipher);
                    break;
                case Core.Enums.CipherType.Site:
                    Data = new SiteDataModel(cipher);
                    break;
                default:
                    throw new ArgumentException("Unsupported " + nameof(Type) + ".");
            }
        }
Ejemplo n.º 2
0
        public SiteResponseModel(Cipher cipher)
            : base("site")
        {
            if (cipher == null)
            {
                throw new ArgumentNullException(nameof(cipher));
            }

            if (cipher.Type != Core.Enums.CipherType.Site)
            {
                throw new ArgumentException(nameof(cipher.Type));
            }

            var data = new SiteDataModel(cipher);

            Id           = cipher.Id.ToString();
            FolderId     = cipher.FolderId?.ToString();
            Favorite     = cipher.Favorite;
            Name         = data.Name;
            Uri          = data.Uri;
            Username     = data.Username;
            Password     = data.Password;
            Notes        = data.Notes;
            RevisionDate = cipher.RevisionDate;
        }
Ejemplo n.º 3
0
        public CipherResponseModel(Cipher cipher)
            : base("cipher")
        {
            if (cipher == null)
            {
                throw new ArgumentNullException(nameof(cipher));
            }

            Id           = cipher.Id.ToString();
            FolderId     = cipher.FolderId?.ToString();
            Type         = cipher.Type;
            Favorite     = cipher.Favorite;
            RevisionDate = cipher.RevisionDate;

            switch (cipher.Type)
            {
            case Core.Enums.CipherType.Folder:
                Data = new FolderDataModel(cipher);
                break;

            case Core.Enums.CipherType.Site:
                Data = new SiteDataModel(cipher);
                break;

            default:
                throw new ArgumentException("Unsupported " + nameof(Type) + ".");
            }
        }
Ejemplo n.º 4
0
        public SiteResponseModel(Cipher cipher)
            : base("site")
        {
            if(cipher == null)
            {
                throw new ArgumentNullException(nameof(cipher));
            }

            if(cipher.Type != Core.Enums.CipherType.Site)
            {
                throw new ArgumentException(nameof(cipher.Type));
            }

            var data = new SiteDataModel(cipher);

            Id = cipher.Id.ToString();
            FolderId = cipher.FolderId?.ToString();
            Favorite = cipher.Favorite;
            Name = data.Name;
            Uri = data.Uri;
            Username = data.Username;
            Password = data.Password;
            Notes = data.Notes;
            RevisionDate = cipher.RevisionDate;
        }