示例#1
0
        /// <summary>
        /// Implements <see cref="IOwnerClient.CreateUpdateAsync" />
        /// </summary>
        public async Task <IEnumerable <Result> > CreateUpdateAsync(IEnumerable <Owner> owners)
        {
            if (owners == null)
            {
                throw new ArgumentException("owner body list cannot be null.");
            }

            if (owners.Count() == 0 || owners.Count() > BatchMaxSize)
            {
                throw new ArgumentException(string.Format("Owner body list cannot be empty or biger that {0}.", BatchMaxSize));
            }

            foreach (Owner owner in owners)
            {
                if (string.IsNullOrEmpty(owner.Username))
                {
                    throw new ArgumentException("username cannot be blank.");
                }
            }

            var asynResult = await client.SendAsyncRequestWithResult(
                HttpMethod.Put,
                "/api/v3/owners",
                OwnerSerializer.SerializeOwners(owners));

            return(JsonConvert.DeserializeObject <IEnumerable <Result> >(asynResult));
        }
示例#2
0
        /// <summary>
        /// Implements <see cref="IOwnerClient.UpdateAsync" />
        /// </summary>
        public async Task UpdateAsync(Owner owner, string username)
        {
            if (owner == null)
            {
                throw new ArgumentException("owner body cannot be null.");
            }

            if (string.IsNullOrEmpty(username))
            {
                throw new ArgumentException("username cannot be blank.");
            }

            await client.SendAsyncRequest(HttpMethod.Put,
                                          string.Format("/api/v3/owners/{0}", username),
                                          OwnerSerializer.SerializeOwner(owner));
        }
示例#3
0
        /// <summary>
        /// Implements <see cref="IOwnerClient.UpdatePasswordAsync" />
        /// </summary>
        public async Task UpdatePasswordAsync(string username, string password)
        {
            if (string.IsNullOrEmpty(username))
            {
                throw new ArgumentException("username cannot be blank.");
            }

            if (string.IsNullOrEmpty(password))
            {
                throw new ArgumentException("password cannot be blank.");
            }

            Owner owner = new Owner.Builder()
            {
                Username = username,
                Password = password
            };

            await client.SendAsyncRequest(HttpMethod.Put,
                                          string.Format("/api/v3/owners/{0}/password", username),
                                          OwnerSerializer.SerializeOwner(owner));
        }
示例#4
0
        /// <summary>
        /// Implements <see cref="IOwnerClient.CreateAsync" />
        /// </summary>
        public async Task CreateAsync(Owner owner)
        {
            if (owner == null)
            {
                throw new ArgumentException("owner body cannot be null.");
            }

            if (string.IsNullOrEmpty(owner.Username))
            {
                throw new ArgumentException("username cannot be blank.");
            }

            if (string.IsNullOrEmpty(owner.Password))
            {
                throw new ArgumentException("password cannot be blank.");
            }

            await client.SendAsyncRequest(
                HttpMethod.Post,
                "/api/v3/owners",
                OwnerSerializer.SerializeOwner(owner));
        }