SHOW:
|
|
- or go back to the newest paste.
| 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 | var jsonObject = JSON.parse(jsonString).result; | |
| 6 | return jsonObject; | |
| 7 | } | |
| 8 | ||
| 9 | function GetItemSellValue(jsonObject) {
| |
| 10 | var adjustedValue = (jsonObject.min_sale_unit_price / 100); | |
| 11 | return adjustedValue; | |
| 12 | } | |
| 13 | ||
| 14 | function SalePriceChangedLastHour(jsonObject) {
| |
| 15 | var adjustedValue = (jsonObject.sale_price_change_last_hour / 100); | |
| 16 | return adjustedValue; | |
| 17 | } | |
| 18 | ||
| 19 | function GetItemBuyValue(jsonObject) {
| |
| 20 | var adjustedValue = (jsonObject.max_offer_unit_price / 100); | |
| 21 | return adjustedValue; | |
| 22 | } | |
| 23 | ||
| 24 | function OfferPriceChangedLastHour(jsonObject) {
| |
| 25 | var adjustedValue = (jsonObject.offer_price_change_last_hour / 100); | |
| 26 | return adjustedValue; | |
| 27 | } | |
| 28 | ||
| 29 | // functions call example for prices of Glob of Ectoplasm: | |
| 30 | ||
| 31 | //get all information about that item (a single HTTP request is made) and save them in a variable | |
| 32 | var ecto = GetItem(19721); | |
| 33 | ||
| 34 | //get adjusted values passing already downloaded object info to adjusting functions | |
| 35 | var sell=GetItemSellValue(ecto); | |
| 36 | var sall_changed=SalePriceChangedLastHour(ecto); | |
| 37 | var buy=GetItemBuyValue(ecto); | |
| 38 | var buy_changed=OfferPriceChangedLastHour(ecto); |