public JSONProductMatchesResponse(string jsonstring) { JSONProductMatchesResponse jsonpmr = DeserializeJSon <JSONProductMatchesResponse>(jsonstring); this.Data = jsonpmr.Data; this.ProcessedDate = jsonpmr.ProcessedDate; this.Succeed = jsonpmr.Succeed; //this.ErrorMessage = jsonpmr.ErrorMessage; }
public bool GetDimensions(string asin, ref double length, ref double width, ref double height, ref double weight) { bool result = false; string tempstring = ""; try { if (ProfitCalcToken == "" && !GetProfitCalcToken()) { ErrorOccurred = true; ErrorMessage = "Es konnte kein Token ermittelt werden"; return(false); } tempstring = GetResponseString("GET", String.Format(MatchesUrl, asin, Language, ProfitCalcToken), ""); if ((tempstring.IndexOf("succeed\":\"false") > 0) | (tempstring.IndexOf("data\":[]") > 0)) { ErrorOccurred = true; ErrorMessage = "Keine ASIN gefunden"; return(false); } JSONProductMatchesResponse jpmr = new JSONProductMatchesResponse(tempstring); length = jpmr.Data[0].Length; width = jpmr.Data[0].Width; height = jpmr.Data[0].Height; weight = jpmr.Data[0].Weight; if (jpmr.Data[0].WeightUnit == "gramms") { weight *= 1000; } result = true; } catch (Exception e) { ErrorMessage = e.Message; ErrorOccurred = true; } return(result); }
public int GetFees(string asin, double price) { string tempstring = ""; if (price == 0) { price = 100; } else { Math.Round(price, 0, MidpointRounding.AwayFromZero); } Fees = new SortedList <string, double>(); try { if (ProfitCalcToken == "" && !GetProfitCalcToken()) { ErrorOccurred = true; ErrorMessage = "Es konnte kein Token ermittelt werden"; return(0); } tempstring = GetResponseString("GET", String.Format(MatchesUrl, asin, Language, ProfitCalcToken), ""); if ((tempstring.IndexOf("succeed\":\"false") > 0) | (tempstring.IndexOf("data\":[]") > 0)) { ErrorOccurred = true; ErrorMessage = "Keine ASIN gefunden"; return(0); } JSONProductMatchesResponse jpmr = new JSONProductMatchesResponse(tempstring); JSONASINFeesRequest jfrequest = new JSONASINFeesRequest(jpmr.Data[0], MarketPlaceID, price, Currency); tempstring = GetResponseString("POST", String.Format(FeeUrl, ProfitCalcToken), jfrequest.ToString()); if (tempstring.IndexOf("succeed\":\"false") > 0) { ErrorOccurred = true; ErrorMessage = "Gebühren konnten nicht abgerufen werden"; return(0); } //MessageBox.Show(tempstring); JSONASINFeeResponse jfresponse = new JSONASINFeeResponse(tempstring); SortedList <string, double> fees = jfresponse.Data.AfnFees.ToASINFeeList(asin, Language); foreach (var item in fees) { Fees.Add(item.Key, item.Value); } fees = jfresponse.Data.MfnFees.ToASINFeeList(asin, Language); foreach (var item in fees) { Fees.Add(item.Key, item.Value); } } catch (Exception e) { ErrorMessage = e.Message; ErrorOccurred = true; } return(Fees.Count); }