private CartAdd GetCartAdd(string cartInfo, Item item, OfferListing offerListing) { CartAdd cartAdd = new CartAdd(); cartAdd.AssociateTag = AssociateTag; cartAdd.AWSAccessKeyId = AWSAccessKeyId; CartAddRequestItem cartItem = new CartAddRequestItem(); //cartItem.ASIN = item.ASIN; cartItem.AssociateTag = AssociateTag; cartItem.OfferListingId = offerListing.OfferListingId; cartItem.Quantity = "1"; CartAddRequest request = new CartAddRequest(); string[] split = cartInfo.Split(','); request.CartId = split[0]; request.HMAC = split[1]; request.Items = new CartAddRequestItem[] {cartItem}; cartAdd.Request = new CartAddRequest[] {request}; return cartAdd; }
public string[] GetPriceTupleFromCart(AWSECommerceService ecs, Item item, OfferListing offerListing) { Cart cart = null; string cartInfo = ReadCartInfo(); if (string.IsNullOrEmpty(cartInfo)) { CartCreateResponse response = ecs.CartCreate(GetCartCreate(item, offerListing)); CheckRequestError(response.OperationRequest); cart = response.Cart[0]; WriteCartInfo(cart); } else { CartAddResponse response = ecs.CartAdd(GetCartAdd(cartInfo, item, offerListing)); CheckRequestError(response.OperationRequest); cart = response.Cart[0]; } string[] prices = new string[2]; prices[0] = cart.SubTotal.Amount; prices[1] = cart.SubTotal.FormattedPrice; CartClearResponse clearResponse = ecs.CartClear(GetCartClear(cart)); CheckRequestError(clearResponse.OperationRequest); return prices; }
public string GetPriceFromCart(AWSECommerceService ecs, Item item, OfferListing offerListing) { string[] prices = GetPriceTupleFromCart(ecs, item, offerListing); return prices[0]; }
private CartCreate GetCartCreate(Item item, OfferListing offerListing) { CartCreate cartCreate = new CartCreate(); cartCreate.AssociateTag = AssociateTag; cartCreate.AWSAccessKeyId = AWSAccessKeyId; CartCreateRequestItem cartItem = new CartCreateRequestItem(); //cartItem.ASIN = item.ASIN; cartItem.AssociateTag = AssociateTag; cartItem.OfferListingId = offerListing.OfferListingId; cartItem.Quantity = "1"; CartCreateRequest request = new CartCreateRequest(); request.Items = new CartCreateRequestItem[] {cartItem}; cartCreate.Request = new CartCreateRequest[] {request}; return cartCreate; }