Guest User

Untitled

a guest
Aug 26th, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function GetItem(itemID) {
  2.   var myUrl = "http://www.gw2spidy.com/api/v0.9/json/item/" + escape(itemID);
  3.   var jsonData = UrlFetchApp.fetch(myUrl);  
  4.   var jsonString = jsonData.getContentText();
  5.   return jsonObject;  
  6. }
  7.  
  8. function GetItemSellValue(jsonObject) {
  9.       var adjustedValue = (jsonObject.min_sale_unit_price / 100);
  10.       return adjustedValue;  
  11. }
  12.      
  13. function SalePriceChangedLastHour(jsonObject) {
  14.       var adjustedValue = (jsonObject.sale_price_change_last_hour / 100);
  15.       return adjustedValue;  
  16. }
  17.      
  18. function GetItemBuyValue(jsonObject) {
  19.       var adjustedValue = (jsonObject.max_offer_unit_price / 100);
  20.       return adjustedValue;
  21. }
  22.      
  23. function OfferPriceChangedLastHour(jsonObject) {
  24.       var adjustedValue = (jsonObject.offer_price_change_last_hour / 100);
  25.       return adjustedValue;
  26. }
  27.  
  28. // functions call example for prices of Glob of Ectoplasm:
  29.  
  30. //get all information about that item (a single HTTP request is made) and save them in a variable
  31. var ecto = GetItem(19721);
  32.  
  33. //get adjusted values passing already downloaded object info to adjusting functions
  34. var sell=GetItemSellValue(ecto);
  35. var sall_changed=SalePriceChangedLastHour(ecto);
  36. var buy=GetItemBuyValue(ecto);
  37. var buy_changed=OfferPriceChangedLastHour(ecto);
Advertisement
Add Comment
Please, Sign In to add comment