Skip to content

Commit 2cf915a

Browse files
committed
Add /v2/characters/:name/quests
1 parent c380736 commit 2cf915a

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

docs/endpoints.md

+16
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ client.language('de').items().all()
9292
- [`api().characters(:name).equipment()`](#apicharactersnameequipment) - Equipment of a single character.
9393
- [`api().characters(:name).heropoints()`](#apicharactersnameheropoints) - Heropoint information of a single character.
9494
- [`api().characters(:name).inventory()`](#apicharactersnameinventory) - Inventory of a single character.
95+
- [`api().characters(:name).quests()`](#apicharactersnamequests) - Completed quests of a single character.
9596
- [`api().characters(:name).recipes()`](#apicharactersnamerecipes) - Unlocked recipes of a single character.
9697
- [`api().characters(:name).sab()`](#apicharactersnamesab) - Zone progress and unlocks in the SAB for this character.
9798
- [`api().characters(:name).skills()`](#apicharactersnameskills) - Skills in use by a single character.
@@ -900,6 +901,21 @@ Alternative method of calling [`api().commerce().transactions()`](#apicommercetr
900901

901902
---
902903

904+
### `api().characters(:name).quests()`
905+
906+
> Completed quests of a single character.
907+
908+
- **API-URL:** [/v2/characters/:name/quests](https://api.guildwars2.com/v2/characters/:name/quests)
909+
- **Paginated:** No
910+
- **Bulk expanding:** No
911+
- **Authenticated:** Yes
912+
- **Localized:** No
913+
- **Cache time:** 5 minutes
914+
915+
<sup>[↑ Back to the overview](#available-endpoints)</sup>
916+
917+
---
918+
903919
### `api().characters(:name).recipes()`
904920

905921
> Unlocked recipes of a single character.

src/endpoints/characters.js

+13
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ module.exports = class CharactersEndpoint extends AbstractEndpoint {
3636
return new InventoryEndpoint(this, this.name)
3737
}
3838

39+
quests () {
40+
return new QuestsEndpoint(this, this.name)
41+
}
42+
3943
recipes () {
4044
return new RecipesEndpoint(this, this.name)
4145
}
@@ -127,6 +131,15 @@ class InventoryEndpoint extends AbstractEndpoint {
127131
}
128132
}
129133

134+
class QuestsEndpoint extends AbstractEndpoint {
135+
constructor (client, character) {
136+
super(client)
137+
this.url = `/v2/characters/${encodeURIComponent(character)}/quests`
138+
this.isAuthenticated = true
139+
this.cacheTime = 5 * 60
140+
}
141+
}
142+
130143
class RecipesEndpoint extends AbstractEndpoint {
131144
constructor (client, character) {
132145
super(client)

tests/endpoints/characters.spec.js

+15
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ describe('endpoints > characters', () => {
113113
expect(content[0].id).toEqual(123)
114114
})
115115

116+
it('test /v2/characters/:id/quests', async () => {
117+
endpoint = (new Module(mockClient, 'Random Nâme')).quests()
118+
119+
expect(endpoint.isPaginated).toEqual(false)
120+
expect(endpoint.isBulk).toEqual(false)
121+
expect(endpoint.isLocalized).toEqual(false)
122+
expect(endpoint.isAuthenticated).toEqual(true)
123+
expect(endpoint.cacheTime).not.toEqual(undefined)
124+
expect(endpoint.url).toEqual('/v2/characters/Random%20N%C3%A2me/quests')
125+
126+
fetchMock.addResponse([42, 40, 337, 295])
127+
let content = await endpoint.get()
128+
expect(content).toEqual([42, 40, 337, 295])
129+
})
130+
116131
it('test /v2/characters/:id/recipes', async () => {
117132
endpoint = (new Module(mockClient, 'Random Nâme')).recipes()
118133

0 commit comments

Comments
 (0)