private Response <SellerTransaction> BuilderErrorResponse(SellerTransaction transaction) { var response = new Response <SellerTransaction> { Item = transaction }; foreach (var error in transaction.Errors) { var e = new MoxiWorksError { Status = "invalid", StatusCode = "0" }; e.Messages.Add(error); response.Errors.Add(e); } return(response); }
/// <summary> /// Update existing Seller Transaction /// </summary> /// <param name="sellerTransaction">The Seller Transaction to be updated.</param> /// <returns>Updated SellerTransaction</returns> public async Task <Response <SellerTransaction> > UpdateSellerTransactionAsync(SellerTransaction sellerTransaction) { sellerTransaction.Validate(); if (sellerTransaction.HasErrors) { return(BuilderErrorResponse(sellerTransaction)); } var builder = new UriBuilder( $"seller_transactions/{sellerTransaction.MoxiWorksTransactionId}"); return(await Client.PutRequestAsync(builder.GetUrl(), sellerTransaction)); }
/// <summary> /// Create new SellerTransaction /// </summary> /// <param name="sellerTransaction">The SellerTransaction to be created.</param> /// <returns>Created SellerTransaction</returns> public async Task <Response <SellerTransaction> > CreateSellerTransactionAsync(SellerTransaction sellerTransaction) { sellerTransaction.Validate(); if (sellerTransaction.HasErrors) { return(BuilderErrorResponse(sellerTransaction)); } var builder = new UriBuilder("seller_transactions"); return(await Client.PostRequestAsync(builder.GetUrl(), sellerTransaction)); }