Ejemplo n.º 1
0
        /// <summary>
        /// Updates the given <see cref="ShopifyCustomer"/>. Id must not be null.
        /// </summary>
        /// <param name="customer">The <see cref="ShopifyCustomer"/> to update.</param>
        /// <returns>The updated <see cref="ShopifyCustomer"/>.</returns>
        public async Task <ShopifyCustomer> UpdateAsync(ShopifyCustomer customer)
        {
            IRestRequest req = RequestEngine.CreateRequest("customers/{0}.json".FormatWith(customer.Id.Value), Method.PUT, "customer");

            req.AddJsonBody(new { customer });

            return(await RequestEngine.ExecuteRequestAsync <ShopifyCustomer>(_RestClient, req));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="ShopifyCustomer"/> on the store.
        /// </summary>
        /// <param name="customer">A new <see cref="ShopifyCustomer"/>. Id should be set to null.</param>
        /// <param name="options">Options for creating the customer.</param>
        /// <returns>The new <see cref="ShopifyCustomer"/>.</returns>
        public async Task <ShopifyCustomer> CreateAsync(ShopifyCustomer customer, ShopifyCustomerCreateOptions options = null)
        {
            IRestRequest req = RequestEngine.CreateRequest("customers.json", Method.POST, "customer");

            //Build the request body
            Dictionary <string, object> body = new Dictionary <string, object>(options?.ToDictionary() ?? new Dictionary <string, object>())
            {
                { "customer", customer }
            };

            req.AddJsonBody(body);

            return(await RequestEngine.ExecuteRequestAsync <ShopifyCustomer>(_RestClient, req));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates the given <see cref="ShopifyCustomer"/>. Id must not be null.
        /// </summary>
        /// <param name="customer">The <see cref="ShopifyCustomer"/> to update.</param>
        /// <param name="options">Options for updating the customer.</param>
        /// <returns>The updated <see cref="ShopifyCustomer"/>.</returns>
        public async Task <ShopifyCustomer> UpdateAsync(ShopifyCustomer customer, ShopifyCustomerUpdateOptions options = null)
        {
            IRestRequest req = RequestEngine.CreateRequest($"customers/{customer.Id.Value}.json", Method.PUT, "customer");

            var customerBody = customer.ToDictionary();

            if (options != null)
            {
                foreach (var keyValuePair in options.ToDictionary())
                {
                    customerBody.Add(keyValuePair);
                }
            }

            var requestBody = new { customer = customerBody };

            req.AddJsonBody(requestBody);

            return(await RequestEngine.ExecuteRequestAsync <ShopifyCustomer>(_RestClient, req));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new <see cref="ShopifyCustomer"/> on the store.
        /// </summary>
        /// <param name="customer">A new <see cref="ShopifyCustomer"/>. Id should be set to null.</param>
        /// <param name="options">Options for creating the customer.</param>
        /// <returns>The new <see cref="ShopifyCustomer"/>.</returns>
        public async Task<ShopifyCustomer> CreateAsync(ShopifyCustomer customer, ShopifyCustomerCreateOptions options = null)
        {
            IRestRequest req = RequestEngine.CreateRequest("customers.json", Method.POST, "customer");

            //Build the request body
            Dictionary<string, object> body = new Dictionary<string, object>(options?.ToDictionary() ?? new Dictionary<string, object>())
            {
                { "customer", customer }
            };

            req.AddJsonBody(body);

            return await RequestEngine.ExecuteRequestAsync<ShopifyCustomer>(_RestClient, req);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Updates the given <see cref="ShopifyCustomer"/>. Id must not be null.
        /// </summary>
        /// <param name="customer">The <see cref="ShopifyCustomer"/> to update.</param>
        /// <returns>The updated <see cref="ShopifyCustomer"/>.</returns>
        public async Task<ShopifyCustomer> UpdateAsync(ShopifyCustomer customer)
        {
            IRestRequest req = RequestEngine.CreateRequest($"customers/{customer.Id.Value}.json", Method.PUT, "customer");

            req.AddJsonBody(new { customer });

            return await RequestEngine.ExecuteRequestAsync<ShopifyCustomer>(_RestClient, req);
        }