Skip to content

Commit 07bc363

Browse files
committed
Added getCurrency
1 parent f5e6af8 commit 07bc363

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

src/gw2api.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ angular.module('redglow.gw2api', [])
1616
provider.recipesEntrySecondsDuration = 60 * 60 * 24;
1717
// listings last for a much shorter time
1818
provider.listingsEntrySecondsDuration = 60;
19+
// currencies last long
20+
provider.currenciesEntrySecondsDuration = 60 * 60 * 24;
1921
// timeout delay
2022
provider.timeoutDelay = 250;
2123
// default language (null => no language sent; value => language value sent)
@@ -181,6 +183,10 @@ angular.module('redglow.gw2api', [])
181183
"recipes",
182184
provider.recipesEntrySecondsDuration,
183185
"https://api.guildwars2.com/v2/recipes"),
186+
currencies: produceRequestsEntry(
187+
"currencies",
188+
provider.currenciesEntrySecondsDuration,
189+
"https://api.guildwars2.com/v2/currencies"),
184190
};
185191

186192
function runRequests(key) {
@@ -413,7 +419,10 @@ angular.module('redglow.gw2api', [])
413419
},
414420
getCurrencies: function() {
415421
return straightCall("https://api.guildwars2.com/v2/currencies");
416-
}
422+
},
423+
getCurrency: function(id) {
424+
return enqueue('currencies', id);
425+
},
417426
};
418427
};
419428

tests/enqueued-spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ describe('GW2API', function() {
187187
testIdInterface('item', 'getItem', globalItems.items, globalItems.prepareItem);
188188
testIdInterface('listing', 'getListing', globalItems.listings, globalItems.prepareListing);
189189
testIdInterface('recipe', 'getRecipe', globalItems.recipes, globalItems.prepareRecipe);
190+
testIdInterface('currency', 'getCurrency', globalItems.currencies, globalItems.prepareCurrency);
190191

191192
describe('', function() {
192193
beforeEach(module('redglow.gw2api', function(GW2APIProvider) {

tests/items-helper.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,6 +2973,21 @@ ctx.recipe843 = {
29732973
"id": 843
29742974
};
29752975

2976+
ctx.currency4 = {
2977+
"id": 4,
2978+
"name": "Gem",
2979+
"description": "Purchased and spent via the Black Lion Trading Company.",
2980+
"order": 0,
2981+
"icon": "https://render.guildwars2.com/file/220061640ECA41C0577758030357221B4ECCE62C/502065.png"
2982+
};
2983+
ctx.currency10 = {
2984+
"id": 10,
2985+
"name": "Manifesto of the Moletariate",
2986+
"description": "Earned in Sorrow's Embrace. Spent in Lion's Arch to purchase rare and exotic gear, runes and sigils, crafting materials, and the \"Gift of the Forgeman\" component used in creating legendary weapons.",
2987+
"order": 140,
2988+
"icon": "https://render.guildwars2.com/file/B83A4ED528FC237D4D1862CDD0250B773EAB36AA/619323.png"
2989+
};
2990+
29762991
ctx.items = {
29772992
24305: ctx.item24305,
29782993
19677: ctx.item19677
@@ -2988,6 +3003,11 @@ ctx.recipes = {
29883003
3166: ctx.recipe3166
29893004
};
29903005

3006+
ctx.currencies = {
3007+
4: ctx.currency4,
3008+
10: ctx.currency10
3009+
};
3010+
29913011
function permute(input) {
29923012
var usedChars = [],
29933013
permArr = [];
@@ -3107,5 +3127,9 @@ ctx.prepareRecipe = function($httpBackend) {
31073127
return basePrepare($httpBackend, ctx.recipes, 'https://api.guildwars2.com/v2/recipes', arguments);
31083128
}
31093129

3130+
ctx.prepareCurrency = function($httpBackend) {
3131+
return basePrepare($httpBackend, ctx.currencies, 'https://api.guildwars2.com/v2/currencies', arguments);
3132+
}
3133+
31103134
return ctx;
31113135
})();

0 commit comments

Comments
 (0)