Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //get all information about an item (a single HTTP request is made), save them in a variable (jsonObject),
- //make necessary adjustment on item's value and return the result
- function GetItem(itemID) {
- var myUrl = "http://www.gw2spidy.com/api/v0.9/json/item/" + escape(itemID);
- var jsonData = UrlFetchApp.fetch(myUrl);
- var jsonString = jsonData.getContentText();
- var jsonObject = JSON.parse(jsonString).result;
- jsonObject.min_sale_unit_price=jsonObject.min_sale_unit_price / 100;
- jsonObject.sale_price_change_last_hour=jsonObject.sale_price_change_last_hour / 100;
- jsonObject.max_offer_unit_price=jsonObject.max_offer_unit_price / 100;
- jsonObject.offer_price_change_last_hour= jsonObject.offer_price_change_last_hour / 100;
- return jsonObject;
- }
- // functions call example for prices of Glob of Ectoplasm:
- var ecto = GetItem(19721);
- //get adjusted values getting property of the item
- var sell=ecto.min_sale_unit_price;
- var sell_changed=ecto.sale_price_change_last_hour;
- var buy=ecto.max_offer_unit_price;
- var buy_changed=ecto.offer_price_change_last_hour;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement