/// <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)); }
/// <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"); 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)); }