Advertisement
Guest User

Untitled

a guest
Aug 26th, 2014
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //get all information about an item (a single HTTP request is made), save them in a variable (jsonObject),
  2. //make necessary adjustment on item's value and return the result
  3. function GetItem(itemID) {
  4.   var myUrl = "http://www.gw2spidy.com/api/v0.9/json/item/" + escape(itemID);
  5.   var jsonData = UrlFetchApp.fetch(myUrl);  
  6.   var jsonString = jsonData.getContentText();
  7.   var jsonObject = JSON.parse(jsonString).result;
  8.   jsonObject.min_sale_unit_price=jsonObject.min_sale_unit_price / 100;
  9.   jsonObject.sale_price_change_last_hour=jsonObject.sale_price_change_last_hour / 100;
  10.   jsonObject.max_offer_unit_price=jsonObject.max_offer_unit_price / 100;
  11.   jsonObject.offer_price_change_last_hour= jsonObject.offer_price_change_last_hour / 100;
  12.   return jsonObject;  
  13. }
  14.  
  15. // functions call example for prices of Glob of Ectoplasm:
  16. var ecto = GetItem(19721);
  17.  
  18. //get adjusted values getting property of the item
  19. var sell=ecto.min_sale_unit_price;
  20. var sell_changed=ecto.sale_price_change_last_hour;
  21. var buy=ecto.max_offer_unit_price;
  22. var buy_changed=ecto.offer_price_change_last_hour;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement