Esempio n. 1
0
        /// <summary>
        /// Creates an empty document wrapper
        /// </summary>
        /// <param name="vaultId">Vault to use</param>
        /// <returns>Path of new document</returns>
        private string CreateDocument(Guid vaultId)
        {
            var client = _restClientFactory.CreateWithAuthentication();

            var request = _restClientFactory.CreateClientRequest($"vaults/{vaultId}/documents", Method.POST);

            var body = $@"
                {{
                  ""metadata"": {{
                    ""createDate"": ""{DateTime.UtcNow:O}"",
                    ""changeDate"": ""{DateTime.UtcNow:O}"",
                    ""name"": ""HelloWorld_{DateTime.UtcNow:O}"",
                    ""size"": 100
                  }}
                }}";

            request.AddJsonBody(body);

            var response = client.Execute <dynamic>(request);

            if (!response.IsSuccessful)
            {
                throw new Exception("Error creating new document");
            }

            return(GetLocation(response));
        }
Esempio n. 2
0
        public IEnumerable <Vault> GetAll()
        {
            var client = _restClientFactory.CreateWithAuthentication();

            var request = _restClientFactory.CreateClientRequest("vaults/", Method.GET);

            var response = client.Execute <List <Vault> >(request);

            if (!response.IsSuccessful)
            {
                throw new Exception("Something went wrong getting vaults");
            }

            return(response.Data);
        }