private static async Task UpdateBazaarFor(DateTime start, DateTime end, DateTime removeBefore) { foreach (var item in await AvgBazzarHistory(start, end)) { await CacheService.Instance.ModifyInRedis <ItemLookup>(GetIntradayKey(item.ItemId), hoursList => { if (hoursList == null) { hoursList = new ItemLookup(); } try { hoursList.AddNew(item); } catch (Exception e) { Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(hoursList)); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(item)); throw e; } hoursList.Discard(removeBefore); return(hoursList); }); } }
private async Task DropYesterDay(TimeSpan aDay, TimeSpan oneHour, DateTime lastHour, DateTime startYesterday, int id, ItemLookup res) { if (res.Oldest.Date != default(DateTime) && res.Oldest.Date < lastHour) { // move the intrahour to hour var hourly = await GetLookupForToday(id); if (hourly == null) { hourly = new ItemLookup(); } var beginOfHour = DateTime.Now.RoundDown(oneHour); var oneHourRecord = res.CombineIntoOne(default(DateTime), beginOfHour); if (oneHourRecord.Avg != 0) { hourly.AddNew(oneHourRecord); } if (hourly.Oldest.Date < startYesterday) { hourly.Discard(DateTime.Now - aDay); //ComputeBazaarPriceFor(id); } await CacheService.Instance.SaveInRedis(GetIntradayKey(id), hourly); } }
public ItemLookupResponse ItemLookUp(List <string> items, ItemLookupRequestIdType id) { try { var request = new ItemLookupRequest { ItemId = items.ToArray(), IdType = id, IdTypeSpecified = true, ResponseGroup = new string[] { "Large", "OfferFull", "OfferListings", "Offers", "OfferSummary", "Images" } }; //new string[] { "132018245828" }; if (id != ItemLookupRequestIdType.ASIN) { request.SearchIndex = "All"; } var amazon = new ItemLookup { AssociateTag = AssociateTag, AWSAccessKeyId = AWSAccessKeyId, Request = new ItemLookupRequest[] { request } }; var resultado = client.ItemLookup(amazon); return(resultado); } catch (Exception ex) { throw ex; } }
public string ReviewsFrame() { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); binding.MaxReceivedMessageSize = int.MaxValue; binding.MaxBufferSize = int.MaxValue; AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient( binding, new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService")); // add authentication to the ECS client amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(ConfigurationManager.AppSettings["accessKeyId"], ConfigurationManager.AppSettings["secretKey"])); ItemLookupRequest request = new ItemLookupRequest(); request.ItemId = this.ItemIds; request.IdType = ItemLookupRequestIdType.ASIN; request.ResponseGroup = new string[] { "Reviews" }; ItemLookup itemLookup = new ItemLookup(); itemLookup.Request = new ItemLookupRequest[] { request }; itemLookup.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"]; itemLookup.AssociateTag = ConfigurationManager.AppSettings["associateTag"]; ItemLookupResponse response = amazonClient.ItemLookup(itemLookup); string frameUrl = response.Items[0].Item[0].CustomerReviews.IFrameURL; return(frameUrl); }
public string getCurrentPrice(string itemID) { const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ"; const string secretKey = "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"; // create a WCF Amazon ECS client AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient( new BasicHttpBinding(BasicHttpSecurityMode.Transport), new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService")); // add authentication to the ECS client client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey)); // prepare an ItemSearch request ItemLookupRequest request = new ItemLookupRequest(); request.ItemId = new string[] { itemID }; request.ResponseGroup = new string[] { "OfferSummary" }; request.MerchantId = "Amazon"; ItemLookup itemSearch = new ItemLookup(); itemSearch.Request = new ItemLookupRequest[] { request }; itemSearch.AWSAccessKeyId = accessKeyId; itemSearch.AssociateTag = "rgreuel-20"; // issue the ItemSearch request ItemLookupResponse response = client.ItemLookup(itemSearch); // write out the results Item returnedItem = response.Items[0].Item.First(); return((returnedItem.OfferSummary.LowestNewPrice.FormattedPrice).Substring(1, returnedItem.OfferSummary.LowestNewPrice.FormattedPrice.Length - 1)); }
public async Task <Item[]> LookupItemsAsync(string[] itemIds) { if (itemIds.Length == 0) { return(new Item[] { }); } var itemLookup = new ItemLookup { AssociateTag = _associateTag, AWSAccessKeyId = _accessKey, Request = new ItemLookupRequest[] { new ItemLookupRequest { ItemId = itemIds.Length > 10 ? itemIds.Take(10).ToArray() : itemIds, IdType = ItemLookupRequestIdType.ASIN, IdTypeSpecified = true, ResponseGroup = new string[] { "Images", "ItemAttributes" } } } }; var lookupResult = await _amazonClient.ItemLookupAsync(new ItemLookupRequest1 { ItemLookup = itemLookup }); var items = lookupResult.ItemLookupResponse.Items[0].Item; return(items.Select(item => ToRetailerItem(item)).ToArray()); }
private static IEnumerable <ItemAlternateVersion> GetAlternateVersions(AWSECommerceServicePortTypeClient client, string asin) { ItemLookupRequest request = new ItemLookupRequest(); request.IdType = ItemLookupRequestIdType.ASIN; request.ItemId = new string[] { asin }; request.ResponseGroup = new string[] { "AlternateVersions" }; ItemLookup lookup = new ItemLookup(); lookup.AWSAccessKeyId = access_key_id; lookup.AssociateTag = associate_tag; lookup.Request = new ItemLookupRequest[] { request }; var response = client.ItemLookup(lookup); if (response.Items != null && response.Items.Count() > 0) { var items = response.Items[0]; if (items.Item != null && items.Item.Count() > 0) { var item = items.Item[0]; if (item.AlternateVersions != null && item.AlternateVersions.Count() > 0) { return(item.AlternateVersions); } } } return(null); }
private static Item[] DoAmazonItemLookup(string[] ASINs) { ItemLookupResponse response = null; AWSECommerceServicePortTypeClient ecs = GetClient(); ItemLookupRequest request = GetLookupRequest(); request.ItemId = ASINs; ItemLookup lookup = new ItemLookup(); lookup.AssociateTag = _ASSOCIATE_TAG; lookup.AWSAccessKeyId = _ACCESS_KEY_ID; // Set the request on the search wrapper lookup.Request = new ItemLookupRequest[] { request }; try { //Send the request and store the response response = ecs.ItemLookup(lookup); } catch (NullReferenceException e) { Debug.WriteLine(e.ToString()); } if (response == null) { throw new Exception("Request did not return a response. Error using Amazon API"); } return(response.Items[0].Item); }
public async Task AddBazaarData(BazaarPull pull) { TimeSpan aDay, oneHour; DateTime lastHour, startYesterday; ComputeTimes(out aDay, out oneHour, out lastHour, out startYesterday); foreach (var item in pull.Products) { var id = ItemDetails.Instance.GetOrCreateItemByTag(item.ProductId); //await CacheService.Instance.ModifyInRedis(GetIntraHourKey(id),) var res = await GetHourlyLookup(id); if (res == null) { res = new ItemLookup(); } res.AddNew(item, pull.Timestamp); await CacheService.Instance.SaveInRedis(GetIntraHourKey(id), res); await DropYesterDay(aDay, oneHour, lastHour, startYesterday, id, res); } if (BazzarItem.Count() == 0) { BazzarItem = pull.Products.ToDictionary(p => ItemDetails.Instance.GetOrCreateItemByTag(p.ProductId), p => true); } }
/// <summary> /// Gets a list of <seealso cref="Items"/> objects based on a list of ASIN strings. /// </summary> /// <param name="asinList">The list of ASIN strings.</param> /// <returns>A list of <seealso cref="Items"/> </returns> public static IEnumerable <Items> GetItemsFromAsinList(IList <string> asinList) { var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); basicHttpBinding.MaxReceivedMessageSize = int.MaxValue; var associateUrl = ConfigurationManager.AppSettings["AssociateUrl"]; var accessKeyId = ConfigurationManager.AppSettings["AccessKeyId"]; var associateSecret = ConfigurationManager.AppSettings["AssociateSecret"]; var associateTag = ConfigurationManager.AppSettings["AssociateTag"]; using (var awseCommerceServicePortTypeClient = new AWSECommerceServicePortTypeClient(basicHttpBinding, new EndpointAddress(associateUrl))) { var amazonEndpointBehavior = new AmazonSigningEndpointBehavior(accessKeyId, associateSecret); awseCommerceServicePortTypeClient.ChannelFactory.Endpoint.Behaviors.Add(amazonEndpointBehavior); var itemLookupRequest = new ItemLookupRequest(); itemLookupRequest.ItemId = asinList.ToArray(); itemLookupRequest.ResponseGroup = new string[] { "ItemAttributes", "Images", "Offers" }; var itemLookup = new ItemLookup(); itemLookup.AssociateTag = associateTag; itemLookup.AWSAccessKeyId = accessKeyId; itemLookup.Request = new ItemLookupRequest[] { itemLookupRequest }; var itemLookupResponse = awseCommerceServicePortTypeClient.ItemLookup(itemLookup); var itemArray = itemLookupResponse.Items; return(itemArray.Cast <Items>()); } }
private ItemLookup FindRemovedItems( ItemLookup lookup1, ItemLookup lookup2) { if (lookup1 == null) { return(new ItemLookup()); } if (lookup2 == null) { return(lookup1); } var results = new ItemLookup(); foreach (var key in lookup1.ItemsById.Keys.Where(key => !lookup2.ItemsById.ContainsKey(key))) { results.ItemsById[key] = lookup1.ItemsById[key]; } foreach (var item in lookup1.ItemsWithNoPkValue) { results.ItemsWithNoPkValue.Add(item); } return(results); }
public void GetBasketTotalWithOffersWithNoLeft() { Dictionary <string, Item> items = new Dictionary <string, Item>() { { "A99", new Item { SKU = "A99", Price = 0.50m } }, }; List <SpecialOffer> specialOffers = new List <SpecialOffer>() { new SpecialOffer() { SKU = "A99", Quantity = 3, Price = 1.30m }, }; ItemLookup itemLookup = new ItemLookup(items); SpecialOfferLookup specialOfferLookup = new SpecialOfferLookup(specialOffers); Checkout checkout = new Checkout(itemLookup, specialOfferLookup); _ = checkout.AddItemToBasket("A99"); _ = checkout.AddItemToBasket("A99"); _ = checkout.AddItemToBasket("A99"); var result = checkout.GetTotalPrice(); Assert.Equal(1.30m, result); }
private static IEnumerable<ItemAlternateVersion> GetAlternateVersions(AWSECommerceServicePortTypeClient client, string asin) { ItemLookupRequest request = new ItemLookupRequest(); request.IdType = ItemLookupRequestIdType.ASIN; request.ItemId = new string[] { asin }; request.ResponseGroup = new string[] { "AlternateVersions" }; ItemLookup lookup = new ItemLookup(); lookup.AWSAccessKeyId = access_key_id; lookup.AssociateTag = associate_tag; lookup.Request = new ItemLookupRequest[] { request }; var response = client.ItemLookup(lookup); if (response.Items != null && response.Items.Count() > 0) { var items = response.Items[0]; if (items.Item != null && items.Item.Count() > 0) { var item = items.Item[0]; if (item.AlternateVersions != null && item.AlternateVersions.Count() > 0) return item.AlternateVersions; } } return null; }
public string ReviewsFrame() { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); binding.MaxReceivedMessageSize = int.MaxValue; binding.MaxBufferSize = int.MaxValue; AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient( binding, new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService")); // add authentication to the ECS client amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(ConfigurationManager.AppSettings["accessKeyId"], ConfigurationManager.AppSettings["secretKey"])); ItemLookupRequest request = new ItemLookupRequest(); request.ItemId = this.ItemIds; request.IdType = ItemLookupRequestIdType.ASIN; request.ResponseGroup = new string[] { "Reviews" }; ItemLookup itemLookup = new ItemLookup(); itemLookup.Request = new ItemLookupRequest[] { request }; itemLookup.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"]; itemLookup.AssociateTag = ConfigurationManager.AppSettings["associateTag"]; ItemLookupResponse response = amazonClient.ItemLookup(itemLookup); string frameUrl = response.Items[0].Item[0].CustomerReviews.IFrameURL; return frameUrl; }
private ItemLookupResponse getItemLookupResponse(List <AmazonInfoFeed> infoFeeds) { // prepare the ItemLookup request var requests = new List <ItemLookupRequest>(); // this should be 5 items only foreach (var infoFeed in infoFeeds) { // create request item type for asin - WE ONLY FIND PRODUCT INFO VIA ASIN ONLY! if (!string.IsNullOrEmpty(infoFeed.ASIN)) { requests.Add(createItemRequestLookup(infoFeed.ASIN, ItemLookupRequestIdType.ASIN)); } } // return null if there is no request available if (!requests.Any()) { return(null); } // create an ItemSearch wrapper var itemLookUp = new ItemLookup(); itemLookUp.AssociateTag = _associateKey; itemLookUp.AWSAccessKeyId = _accessKey; itemLookUp.Request = requests.ToArray(); // send the ItemLookup request return(_client.ItemLookup(itemLookUp)); }
private Items[] LookForAsin(string iAsin) { ItemLookupRequest request = new ItemLookupRequest(); request.ResponseGroup = new string[] { "Medium", "Tracks" }; request.ItemId = new string[] {iAsin}; request.IdType = ItemLookupRequestIdType.ASIN; //request.IdTypeSpecified = true; request.Condition = Condition.All; request.IncludeReviewsSummary = "False"; //request.SearchIndex = "All"; //myItemLookup.Validate = "False"; //myItemLookup.XMLEscaping = "Single"; ItemLookup myItemLookup = new ItemLookup(); myItemLookup.Request = new ItemLookupRequest [] {request}; //myItemLookup.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"]; //myItemLookup.AssociateTag = ConfigurationManager.AppSettings["secretKey"]; myItemLookup.AWSAccessKeyId = _IWebServicesManager.AmazonaccessKeyId; myItemLookup.AssociateTag = _IWebServicesManager.AmazonsecretKey; ItemLookupResponse response = _AmazonClient.ItemLookup(myItemLookup); return response.Items; }
private string getImageURL(string asin) { const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ"; const string secretKey = "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"; // create a WCF Amazon ECS client AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient( new BasicHttpBinding(BasicHttpSecurityMode.Transport), new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService")); // add authentication to the ECS client client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey)); // prepare an ItemSearch request ItemLookupRequest request = new ItemLookupRequest(); request.ItemId = new string[] { asin }; request.ResponseGroup = new string[] { "Images" }; request.MerchantId = "Amazon"; ItemLookup itemSearch = new ItemLookup(); itemSearch.Request = new ItemLookupRequest[] { request }; itemSearch.AWSAccessKeyId = accessKeyId; itemSearch.AssociateTag = "rgreuel-20"; // issue the ItemSearch request ItemLookupResponse response = client.ItemLookup(itemSearch); Item returnedItem = response.Items[0].Item.First(); return("<img src=\"" + returnedItem.MediumImage.URL + "\"/>"); }
private void AddItemToDictionary(long?key, string value) { if (key.HasValue && !ItemLookup.ContainsKey(key.Value)) { ItemLookup.Add(key.Value, value); } }
private ItemLookup CreateItemLookup(ItemLookupRequest lookupRequest) { ItemLookup lookup = new ItemLookup(); lookup.AssociateTag = AssociateTag; lookup.Request = new ItemLookupRequest[] { lookupRequest }; return(lookup); }
public ItemLookupResponse Lookup(ItemLookupRequest lookupRequest) { ItemLookup lookup = CreateItemLookup(lookupRequest); AWSECommerceService api = GetService(); ItemLookupResponse response = api.ItemLookup(lookup); return(response); }
public void Add(Engine renderingEngine, SwitchBase sw) { sw.Id = _currentSwitchId; ItemLookup.Add(_currentSwitchId, sw); Items.Add(sw); sw.Initialize(renderingEngine); _currentSwitchId++; }
protected virtual async Task <Resonse> RespondIntraHour(int itemId, string tag) { ItemLookup res = await GetHourlyLookup(itemId); if (res != null) { return(FromItemLookup(res, tag)); } throw new CoflnetException("404", "there was no data found for this item. retry in a miniute"); }
protected virtual async Task <Resonse> RespondHourly(int itemId, string tag) { ItemLookup res = await GetLookupForToday(itemId); if (res != null) { return(FromItemLookup(res, tag, (await GetHourlyLookup(itemId))?.CombineIntoOne(default(DateTime), DateTime.Now))); } throw new CoflnetException("404", "there was no data found for this item. retry in a miniute"); }
public void GetIncorrectItem() { Dictionary <string, Item> items = new Dictionary <string, Item>(); ItemLookup itemLookup = new ItemLookup(items); var item = itemLookup.GetItem("IDontExist"); Assert.Null(item); }
void Start() { delays.Add(transform.Find("delay1").GetComponent <SpriteRenderer>()); delays.Add(transform.Find("delay2").GetComponent <SpriteRenderer>()); delays.Add(transform.Find("delay3").GetComponent <SpriteRenderer>()); ResetDelays(); indicatorLight = transform.Find("light").GetComponent <Light>(); baseIntensity = indicatorLight.intensity; careCoinSymbol = transform.Find("CareCoinSymbol").GetComponent <SpriteRenderer>(); itemIcon = transform.Find("ItemIcon").GetComponent <SpriteRenderer>(); poorIcon = transform.Find("poorIcon").GetComponent <SpriteRenderer>(); poorIcon.gameObject.SetActive(false); available = true; // Attempt to fetch the provided item sprite ItemLookup lookup = AllSprites[0]; if (ItemKey != "") { lookup = AllSprites.Find((ItemLookup l) => l.Type == Type && l.Key == ItemKey); itemSprite = lookup?.ItemSprite; } // If there is nothing set, for the set item is invalid, choose at random among the Type if (itemSprite == null) { var lookupsByType = AllSprites.FindAll((ItemLookup l) => l.Type == Type); lookup = lookupsByType[Mathf.FloorToInt(Random.Range(0, lookupsByType.Count))]; itemSprite = lookup.ItemSprite; } itemIcon.sprite = itemSprite; lookupKey = lookup.Key; switch (Type) { case ItemType.Weapon: item = ItemDB.Weapons[lookupKey]; break; case ItemType.Upgrade: item = ItemDB.Upgrades[lookupKey]; break; case ItemType.Charity: item = ItemDB.Charity[lookupKey]; break; } itemPrice = item.price; priceText = transform.Find("price").GetComponent <TextMesh>(); priceText.text = itemPrice + "cc"; }
public void UpdateSwitches(Engine renderingEngine) { foreach (var switchBase in Items) { switchBase.Initialize(renderingEngine); } foreach (var switchBase in Items) { ItemLookup.Add(switchBase.Id, switchBase); } }
private async Task AddAuction(TimeSpan aDay, TimeSpan oneHour, DateTime lastHour, DateTime startYesterday, SaveAuction auction) { var id = ItemDetails.Instance.GetItemIdForName(auction.Tag); var res = await GetHourlyLookup(id); if (res == null) { res = new ItemLookup(); } res.AddNew(auction); await CacheService.Instance.SaveInRedis(GetIntraHourKey(id), res, TimeSpan.FromHours(1)); await DropYesterDay(aDay, oneHour, lastHour, startYesterday, id, res); }
public void AddIncorrectItemToBasket() { Dictionary <string, Item> items = new Dictionary <string, Item>(); ItemLookup itemLookup = new ItemLookup(items); SpecialOfferLookup specialOfferLookup = new SpecialOfferLookup(new List <SpecialOffer>()); Checkout checkout = new Checkout(itemLookup, specialOfferLookup); var result = checkout.AddItemToBasket("IDontExist"); Assert.False(result); }
private static void GetVariations(AWSECommerceServicePortTypeClient client, string asin) { ItemLookupRequest request = new ItemLookupRequest(); request.IdType = ItemLookupRequestIdType.ASIN; request.ItemId = new string[] { asin }; request.ResponseGroup = new string[] { "Variations" }; ItemLookup lookup = new ItemLookup(); lookup.AWSAccessKeyId = access_key_id; lookup.AssociateTag = associate_tag; lookup.Request = new ItemLookupRequest[] { request }; var response = client.ItemLookup(lookup); }
private static ItemLookupResponse ItemLookup(AWSECommerceServicePortTypeClient client, string asin) { ItemLookupRequest request = new ItemLookupRequest(); request.IdType = ItemLookupRequestIdType.ASIN; request.ItemId = new string[] { asin }; request.ResponseGroup = new string[] { "Large", "ItemAttributes", "AlternateVersions", "Variations" }; ItemLookup lookup = new ItemLookup(); lookup.AWSAccessKeyId = access_key_id; lookup.AssociateTag = associate_tag; lookup.Request = new ItemLookupRequest[] { request }; var response = client.ItemLookup(lookup); return response; }
public void GetCorrectItem() { Dictionary <string, Item> items = new Dictionary <string, Item>() { { "A99", new Item { SKU = "A99", Price = 0.50m } }, }; ItemLookup itemLookup = new ItemLookup(items); var item = itemLookup.GetItem("A99"); Assert.Equal("A99", item.SKU); Assert.Equal(0.50m, item.Price); }
static void Main(string[] args) { // If you are using a debugging proxy like Fiddler to capture SOAP // envelopes, and you get SSL Certificate warnings, uncomment the // following line: // ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; // Create an ItemLookup request, with ResponseGroup "Small" // and using the item ID provided above. ItemLookup itemLookup = new ItemLookup(); itemLookup.AWSAccessKeyId = MY_AWS_ID; ItemLookupRequest itemLookupRequest = new ItemLookupRequest(); itemLookupRequest.ItemId = new String[] { ITEM_ID }; itemLookupRequest.ResponseGroup = new String[] { "Small", "AlternateVersions" }; itemLookup.Request = new ItemLookupRequest[] { itemLookupRequest }; // create an instance of the serivce AWSECommerceService api = new AWSECommerceService(); // set the destination api.Destination = new Uri(DESTINATION); // apply the security policy, which will add the require security elements to the // outgoing SOAP header AmazonHmacAssertion amazonHmacAssertion = new AmazonHmacAssertion(MY_AWS_ID, MY_AWS_SECRET); api.SetPolicy(amazonHmacAssertion.Policy()); // make the call and print the title if it succeeds try { ItemLookupResponse itemLookupResponse = api.ItemLookup(itemLookup); Item item = itemLookupResponse.Items[0].Item[0]; System.Console.WriteLine(item.ItemAttributes.Title); } catch (Exception e) { System.Console.Error.WriteLine(e); } // we're done System.Console.WriteLine("HMAC sample finished. Hit Enter to terminate."); System.Console.ReadLine(); }
public ItemLookupResponse ItemLookupCustom(string asin) { var lookup = new ItemLookup(); var request = new ItemLookupRequest { IdType = ItemLookupRequestIdType.ASIN, IdTypeSpecified = true, ItemId = new[] { asin }, ResponseGroup = new[] { "ItemAttributes", "OfferFull", "Reviews", "Large" } }; //request.SearchIndex = "All"; lookup.AWSAccessKeyId = AccessKey; lookup.AssociateTag = AssociateTag; lookup.Request = new[] { request }; return(client.ItemLookup(lookup)); }
public ItemLookupResponse ItemLookupCustom(string asin) { var lookup = new ItemLookup(); var request = new ItemLookupRequest { IdType = ItemLookupRequestIdType.ASIN, IdTypeSpecified = true, ItemId = new[] { asin }, ResponseGroup = new[] { "ItemAttributes", "OfferFull", "Reviews", "Large" } }; //request.SearchIndex = "All"; lookup.AWSAccessKeyId = AccessKey; lookup.AssociateTag = AssociateTag; lookup.Request = new[] { request }; return client.ItemLookup(lookup); }
public void AddCorrectItemToBasket() { Dictionary <string, Item> items = new Dictionary <string, Item>() { { "A99", new Item { SKU = "A99", Price = 0.50m } }, }; ItemLookup itemLookup = new ItemLookup(items); SpecialOfferLookup specialOfferLookup = new SpecialOfferLookup(new List <SpecialOffer>()); Checkout checkout = new Checkout(itemLookup, specialOfferLookup); var result = checkout.AddItemToBasket("A99"); Assert.True(result); }
public async Task<Item[]> LookupItemsAsync(string[] itemIds) { if (itemIds.Length == 0) { return new Item[] { }; } var itemLookup = new ItemLookup { AssociateTag = _associateTag, AWSAccessKeyId = _accessKey, Request = new ItemLookupRequest[] { new ItemLookupRequest { ItemId = itemIds.Length > 10 ? itemIds.Take(10).ToArray() : itemIds, IdType = ItemLookupRequestIdType.ASIN, IdTypeSpecified = true, ResponseGroup = new string[]{ "Images", "ItemAttributes" } } } }; var lookupResult = await _amazonClient.ItemLookupAsync(new ItemLookupRequest1 { ItemLookup = itemLookup }); var items = lookupResult.ItemLookupResponse.Items[0].Item; return items.Select(item => ToRetailerItem(item)).ToArray(); }
private static void ItemLookupFunc(IEnumerable<Item> items) { foreach (var item in items) { var itemlookuprequest = new ItemLookupRequest { ResponseGroup = new string[] { "Offers" }, IdType = ItemLookupRequestIdType.ASIN, ItemId = new string[] { item.ASIN } }; var itemlookup = new ItemLookup { Request = new ItemLookupRequest[] {itemlookuprequest}, AWSAccessKeyId = AwsAccessKeyId, AssociateTag = AssociateTag }; if (_itemlookupresponse == null) { try { _itemlookupresponse = AmazonClient.ItemLookup(itemlookup); } catch (ServerTooBusyException) { Items.Clear(); ItemSearchFunc(); break; } } Items.Add(item.ItemAttributes.Title + " " + _itemlookupresponse.Items[0].Item[0].OfferSummary.LowestUsedPrice.FormattedPrice); if (Items.Count != PerPage) continue; Display(Items); break; } if (Items.Count >= PerPage) return; _itemPage++; ItemSearchFunc(); }
private string InitRuntime(string toolsVersion, string frameworkDir, bool hardReferences) { _items = new ItemLookup(); _toolsVersion = toolsVersion; _engine = new Engine( frameworkDir ); Log.Verbose("Using build engine: {0}", _engine.GetType().Assembly.FullName); string version = _engine.GetType().Assembly.GetName().Version.ToString(2); Is35 = version == "3.5"; if (hardReferences) { _engine.GlobalProperties.SetProperty("AssemblySearchPaths", "{HintPathFromItem}"); //{CandidateAssemblyFiles} //{HintPathFromItem} //{TargetFrameworkDirectory} //{Registry:Software\Microsoft\.NetFramework,v2.0,AssemblyFoldersEx} //{AssemblyFolders} //{GAC} //{RawFileName} //$(OutputPath) _engine.GlobalProperties.SetProperty("NoStdLib", true.ToString()); } if( !Is35 ) _engine.GlobalProperties.SetProperty("MSBuildToolsPath", frameworkDir); ConsoleLogger trace = new Microsoft.Build.BuildEngine.ConsoleLogger( LoggerVerbosity.Minimal, ConsoleWrite, ColorSetter, ColorResetter ); trace.SkipProjectStartedText = false; trace.ShowSummary = false; _engine.RegisterLogger(trace); return version; }
// POST api/items public HttpResponseMessage Post([FromBody]string ean, [FromBody]int friendId) { if (!string.IsNullOrEmpty(ean)) { var search = new ItemLookup(); var lst = search.Search(ean, ItemLookup.SearchTypeE.EAN); if (lst.Count > 0) { var m = lst.First(); m.OwnerID = friendId; var result = Repository.UpdateItem(m); return new HttpResponseMessage() {StatusCode = HttpStatusCode.OK}; } return new HttpResponseMessage() { StatusCode = HttpStatusCode.NotFound }; } return new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest }; ; }
private void btnLivreAmazonRecherche_Click(object sender, EventArgs e) { ItemLookupResponse response; AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient("AWSECommerceServicePort"); client.ChannelFactory.Endpoint.EndpointBehaviors.Add( new AmazonSigningEndpointBehavior(ConfigurationManager.AppSettings.Get("accessKeyId"), ConfigurationManager.AppSettings.Get("secretKey"))); ItemLookupRequest recherche_ISBN = new ItemLookupRequest(); recherche_ISBN.SearchIndex = "Books"; recherche_ISBN.ItemId = new string[] { txtISBN.Text }; recherche_ISBN.IdType = ItemLookupRequestIdType.ISBN; recherche_ISBN.IdTypeSpecified = true; recherche_ISBN.ResponseGroup = new string[] { "Images", "Small" }; ItemLookup itemlookup = new ItemLookup(); itemlookup.Request = new ItemLookupRequest[] { recherche_ISBN }; itemlookup.AWSAccessKeyId = ConfigurationManager.AppSettings.Get("accessKeyId"); itemlookup.AssociateTag = ConfigurationManager.AppSettings.Get("associateTag"); try { response = client.ItemLookup(itemlookup); foreach (var item in response.Items[0].Item) { txtTitre.Text = item.ItemAttributes.Title; txtAuteur.Text = item.ItemAttributes.Author[0]; // Create a web request to the URL for the picture WebRequest webRequest = HttpWebRequest.Create(item.MediumImage.URL); // Execute the request synchronuously HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); // Create an image from the stream returned by the web request pictureBoxLivre.Image = new System.Drawing.Bitmap(webResponse.GetResponseStream()); WebClient clientWeb = new WebClient(); _cover = clientWeb.DownloadData(item.MediumImage.URL); // Finally, close the request webResponse.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// by UPC or ASIN /// </summary> /// <param name="product"></param> public static void Do(Product product) { // create a WCF Amazon ECS client AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient( new BasicHttpBinding(BasicHttpSecurityMode.Transport) { MaxReceivedMessageSize = int.MaxValue, MaxBufferSize=int.MaxValue, ReaderQuotas = new XmlDictionaryReaderQuotas() { MaxStringContentLength = int.MaxValue } }, new EndpointAddress(DESTINATION)); // add authentication to the ECS client client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(MY_AWS_ID, MY_AWS_SECRET)); // prepare an ItemSearch request ItemLookup itemLookup = new ItemLookup(); itemLookup.AWSAccessKeyId = MY_AWS_ID; itemLookup.AssociateTag = "modkitdesgui-20"; ItemLookupRequest itemLookupRequest = new ItemLookupRequest(); if (!string.IsNullOrEmpty(product.UPC)) { itemLookupRequest.IdType = ItemLookupRequestIdType.UPC; itemLookupRequest.IdTypeSpecified = true; itemLookupRequest.ItemId = new[] { product.UPC }; } else if (!string.IsNullOrEmpty(product.AmazonASIN)) { itemLookupRequest.IdType = ItemLookupRequestIdType.ASIN; itemLookupRequest.IdTypeSpecified = true; itemLookupRequest.ItemId = new[] { product.AmazonASIN }; } else { return; } itemLookupRequest.SearchIndex = "All"; itemLookupRequest.ResponseGroup = new String[] { "Large" }; itemLookup.Request = new ItemLookupRequest[] { itemLookupRequest }; // make the call and print the title if it succeeds try { ItemLookupResponse itemLookupResponse = client.ItemLookup(itemLookup); //search by upc, it may return more than 1 items!!! if (itemLookupResponse.Items.Length == 0 || itemLookupResponse.Items[0].Item == null || itemLookupResponse.Items[0].Item.Length == 0) return; Item item = itemLookupResponse.Items[0].Item[0]; foreach (Item ritem in itemLookupResponse.Items[0].Item) { if (!string.IsNullOrEmpty(product.UPC) && ritem.ItemAttributes.UPC == product.UPC) { item = ritem; break; } } // if (item.ItemAttributes.Feature != null) foreach (var feature in item.ItemAttributes.Feature) { product.Features.Add(new Feature() { Desc = feature }); } // product.AmazonDetailsUrl = item.DetailPageURL; int.TryParse(item.SalesRank, out product.AmazonSaleRank); product.AmazonASIN = item.ASIN; product.UPC = item.ItemAttributes.UPC; if (string.IsNullOrEmpty(product.Name)) product.Name = item.ItemAttributes.Title; if (item.ItemAttributes.ListPrice != null) { decimal.TryParse(item.ItemAttributes.ListPrice.Amount, out product.AmazonPrice); } if (item.OfferSummary.LowestNewPrice != null) { decimal lowestPrice; if (decimal.TryParse(item.OfferSummary.LowestNewPrice.Amount, out lowestPrice) && lowestPrice > 0) product.AmazonPrice = lowestPrice; } product.AmazonPrice /= 100; if (string.IsNullOrEmpty(product.LargeImageUrl) || product.LargeImageUrl.Contains("default_hardlines")) product.LargeImageUrl = item.LargeImage.URL; if (string.IsNullOrEmpty(product.ThumbnailImageUrl) || product.LargeImageUrl.Contains("default_hardlines")) product.ThumbnailImageUrl = item.SmallImage.URL; // if (item.SimilarProducts != null) { foreach (var similarProduct in item.SimilarProducts) { product.SimilarProducts.Add(new Product() { AmazonASIN = similarProduct.ASIN, Name = similarProduct.Title }); } } } catch (Exception e) { Logger.Error("Amazon Error", e); } }
private string getImageURL(string asin) { const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ"; const string secretKey = "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"; // create a WCF Amazon ECS client AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient( new BasicHttpBinding(BasicHttpSecurityMode.Transport), new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService")); // add authentication to the ECS client client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey)); // prepare an ItemSearch request ItemLookupRequest request = new ItemLookupRequest(); request.ItemId = new string[] { asin }; request.ResponseGroup = new string[] { "Images" }; request.MerchantId = "Amazon"; ItemLookup itemSearch = new ItemLookup(); itemSearch.Request = new ItemLookupRequest[] { request }; itemSearch.AWSAccessKeyId = accessKeyId; itemSearch.AssociateTag = "rgreuel-20"; // issue the ItemSearch request ItemLookupResponse response = client.ItemLookup(itemSearch); Item returnedItem = response.Items[0].Item.First(); return "<img src=\"" + returnedItem.MediumImage.URL + "\"/>"; }
public string getCurrentPrice(string itemID) { const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ"; const string secretKey = "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"; // create a WCF Amazon ECS client AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient( new BasicHttpBinding(BasicHttpSecurityMode.Transport), new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService")); // add authentication to the ECS client client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey)); // prepare an ItemSearch request ItemLookupRequest request = new ItemLookupRequest(); request.ItemId = new string[] { itemID }; request.ResponseGroup = new string[] { "OfferSummary" }; request.MerchantId = "Amazon"; ItemLookup itemSearch = new ItemLookup(); itemSearch.Request = new ItemLookupRequest[] { request }; itemSearch.AWSAccessKeyId = accessKeyId; itemSearch.AssociateTag = "rgreuel-20"; // issue the ItemSearch request ItemLookupResponse response = client.ItemLookup(itemSearch); // write out the results Item returnedItem = response.Items[0].Item.First(); return (returnedItem.OfferSummary.LowestNewPrice.FormattedPrice).Substring(1, returnedItem.OfferSummary.LowestNewPrice.FormattedPrice.Length - 1); }
// the program starts here static void Main(string[] args) { // create a WCF Amazon ECS client BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); binding.MaxReceivedMessageSize = int.MaxValue; AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient( binding, new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService")); // add authentication to the ECS client client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey)); ItemLookupRequest request2 = new ItemLookupRequest(); request2.ItemId = new String[] { "2817801997" }; request2.IdType = ItemLookupRequestIdType.ISBN; request2.ResponseGroup = new String[] { "Medium" }; request2.IdTypeSpecified = true; request2.SearchIndex = "Books"; ItemLookup itemLookup = new ItemLookup(); itemLookup.Request = new ItemLookupRequest[] { request2 }; itemLookup.AWSAccessKeyId = accessKeyId; itemLookup.AssociateTag = "213"; ItemLookupResponse response2 = client.ItemLookup(itemLookup); foreach (var item in response2.Items[0].Item) { // Create a web request to the URL for the picture System.Net.WebRequest webRequest = HttpWebRequest.Create(item.MediumImage.URL); // Execute the request synchronuously HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); // Create an image from the stream returned by the web request //pCover.Image = new System.Drawing.Bitmap(webResponse.GetResponseStream()); // Finally, close the request webResponse.Close(); Console.WriteLine(item.ItemAttributes.Title); } // prepare an ItemSearch request ItemSearchRequest request = new ItemSearchRequest(); request.SearchIndex = "Books"; request.Title = "Node.js"; request.ResponseGroup = new string[] { "Small" }; ItemSearch itemSearch = new ItemSearch(); itemSearch.Request = new ItemSearchRequest[] { request }; //itemSearch.AssociateTag = "testsite09f-21"; itemSearch.AssociateTag = "213"; itemSearch.AWSAccessKeyId = accessKeyId; // issue the ItemSearch request ItemSearchResponse response = client.ItemSearch(itemSearch); // write out the results foreach (var item in response.Items[0].Item) { Console.WriteLine(item.ItemAttributes.Title); } Console.ReadLine(); }