/// <summary> /// <para>This request creates a new order and returns the checkout to the webshop.</para> /// <para>You can add preset values to the call, as well. These values will prefill the identification in the checkout. If a preset value has IsReadOnly, the customer will not be able to modify the value.</para> /// </summary> /// <param name="data"><see cref="CreateOrderModel" /></param> /// <returns><see cref="CheckoutOrder" /></returns> public async Task <SveaApiResponse <CheckoutOrder> > CreateOrderAsync(CreateOrderModel data) { data.Validate(); string requestUrl = $"{_baseApiUrl}/api/orders"; AuthenticateRequest(data); var createOrderRequest = await ApiClient.PostAsync(requestUrl, new StringContent(SveaUtils.ObjectToJsonConverter(data), Encoding.UTF8, "application/json") ); return(await HandleResponse <CheckoutOrder>(createOrderRequest, HttpStatusCode.Created, HttpStatusCode.OK)); }
/// <summary> /// This request replaces the order rows of the specified order with the new appended in the call and sets the MerchantData on the order to the provided value. /// <para>HTTP status code 200 indicates success, everything else indicates a failure.</para> /// </summary> /// <param name="orderId">The order Id you got from either <see cref="GetOrderAsync" /> or have stored since earlier</param> /// <param name="data"><see cref="UpdateOrderModel" /></param> /// <returns><see cref="CheckoutOrder" /></returns> public async Task <SveaApiResponse <CheckoutOrder> > UpdateOrderAsync(long orderId, UpdateOrderModel data) { data.Validate(); string requestUrl = $"{_baseApiUrl}/api/orders/{orderId}"; AuthenticateRequest(data); var updateOrderRequest = await ApiClient.PostAsync(requestUrl, new StringContent(SveaUtils.ObjectToJsonConverter(data), Encoding.UTF8, "application/json") ); return(await HandleResponse <CheckoutOrder>(updateOrderRequest)); }