Skip to content

Commit

Permalink
Decorations, Glyphs and Decorations/Categories endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Ecmelt committed Sep 5, 2024
1 parent ead7042 commit fde423c
Show file tree
Hide file tree
Showing 10 changed files with 273 additions and 2 deletions.
82 changes: 81 additions & 1 deletion docs/endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ client.language('de').items().all()
- [`api().account().gliders()`](#apiaccountgliders) - The unlocked gliders of the account.
- [`api().account().home().cats()`](#apiaccounthomecats) - The unlocked cats in the home instance of the account.
- [`api().account().home().nodes()`](#apiaccounthomenodes) - The unlocked nodes in the home instance of the account.
- ['api().account().homestead().decorations()`](#apiaccounthomesteaddecorations) - The account's currently used decorations in homestead.
- ['api().account().homestead().glyphs()`](#apiaccounthomesteadglyphs) - The account's glyphs stored in homestead.
- [`api().account().inventory()`](#apiaccountinventory) - The shared inventory slots of the account.
- [`api().account().jadebots()`](#apiaccountjadebots) - The unlocked jadebots of the account.
- [`api().account().legendaryarmory()`](#apiaccountlegendaryarmory) - The items in the legendary armory of the account.
Expand Down Expand Up @@ -83,7 +85,7 @@ client.language('de').items().all()
- [`api().account().wizardsvault().daily()`](#apiaccountwizardsvaultdaily) - The account's daily objectives in the Wizard's Vault.
- [`api().account().wizardsvault().weekly()`](#apiaccountwizardsvaultweekly) - The account's weekly objectives in the Wizard's Vault.
- [`api().account().wizardsvault().special()`](#apiaccountwizardsvaultspecial) - The account's seasonal objectives in the Wizard's Vault.
- [`api().account().worldbosses()`](#apiaccountworldbosses) - The daily worldbosses completed by the account. 
- [`api().account().worldbosses()`](#apiaccountworldbosses) - The daily worldbosses completed by the account.
- [`api().achievements()`](#apiachievements) - Information about achievements.
- [`api().achievements().categories()`](#apiachievementscategories) - The categories for achievements.
- [`api().achievements().groups()`](#apiachievementsgroups) - The top-level groups for achievements.
Expand Down Expand Up @@ -141,6 +143,9 @@ client.language('de').items().all()
- [`api().guild().treasury()`](#apiguildtreasury) - Information about the items in the guild's treasury.
- [`api().home().cats()`](#apihomecats) - Information about home instance cats.
- [`api().home().nodes()`](#apihomenodes) - Information about home instance nodes.
- ['api().homestead().decorations()`](#apihomesteaddecorations) - Information about homestead decorations.
- ['api().homestead().decorations().categories()`](#apihomesteaddecorationscategories) - Information about homestead decoration categories.
- ['api().homestead().glyphs()`](#apihomesteadglyphs) - Information about glyphs in homestead.
- [`api().items()`](#apiitems) - Information about items that were discovered by players.
- [`api().itemstats()`](#apiitemstats) - Information about stats for items.
- [`api().mailcarriers()`](#apimailcarriers) - Information about mailcarriers.
Expand Down Expand Up @@ -387,6 +392,36 @@ Alternative method of calling [`api().commerce().delivery()`](#apicommercedelive

---

### `api().account().homestead().decorations()`

> The account's currently used decorations in homestead.
- **API-URL:** [/v2/account/homestead/decorations](https://api.guildwars2.com/v2/account/homestead/decorations)
- **Paginated:** No
- **Bulk expanding:** No
- **Authenticated:** Yes
- **Localized:** No
- **Cache time:** 5 minutes

<sup>[↑ Back to the overview](#available-endpoints)</sup>

---

### `api().account().homestead().glyphs()`

> The account's glyphs stored in homestead.
- **API-URL:** [/v2/account/homestead/glyphs](https://api.guildwars2.com/v2/account/homestead/glyphs)
- **Paginated:** No
- **Bulk expanding:** No
- **Authenticated:** Yes
- **Localized:** No
- **Cache time:** 5 minutes

<sup>[↑ Back to the overview](#available-endpoints)</sup>

---

### `api().account().inventory()`

> The shared inventory slots of the account.
Expand Down Expand Up @@ -1656,6 +1691,51 @@ Alternative method of calling [`api().commerce().transactions()`](#apicommercetr

---

### `api().homestead().decorations()`

> Information about homestead decorations.
- **API-URL:** [/v2/homestead/decorations](https://api.guildwars2.com/v2/homestead/decorations)
- **Paginated:** Yes
- **Bulk expanding:** Yes
- **Authenticated:** No
- **Localized:** No
- **Cache time:** 24 hours

<sup>[↑ Back to the overview](#available-endpoints)</sup>

---

### `api().homestead().decorations().categories()`

> Information about homestead decoration categories.
- **API-URL:** [/v2/homestead/decorations/categories](https://api.guildwars2.com/v2/homestead/decorations/categories)
- **Paginated:** Yes
- **Bulk expanding:** Yes
- **Authenticated:** No
- **Localized:** No
- **Cache time:** 24 hours

<sup>[↑ Back to the overview](#available-endpoints)</sup>

---

### `api().homestead().glyphs()`

> Information about glyphs in homestead.
- **API-URL:** [/v2/homestead/glyphs](https://api.guildwars2.com/v2/homestead/glyphs)
- **Paginated:** Yes
- **Bulk expanding:** Yes
- **Authenticated:** No
- **Localized:** No
- **Cache time:** 24 hours

<sup>[↑ Back to the overview](#available-endpoints)</sup>

---

### `api().items()`

> Information about items that were discovered by players.
Expand Down
4 changes: 4 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ module.exports = class Client {
return new endpoints.HomeEndpoint(this)
}

homestead() {
return new endpoints.HomesteadEndpoint(this)
}

items () {
return new endpoints.ItemsEndpoint(this)
}
Expand Down
4 changes: 3 additions & 1 deletion src/endpoints/account-blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ function blob (parent) {
guilds: wrap(() => accountGuilds(client)),
'home.cats': wrap(() => client.account().home().cats().get()),
'home.nodes': wrap(() => client.account().home().nodes().get()),
'homestead.decorations': wrap(() => client.account().homestead().decorations().get()),
'homestead.glyphs': wrap(() => client.account().homestead().glyphs().get()),
jadebots: wrap(() => client.account().jadebots().get()),
legendaryarmory: wrap(() => client.account().legendaryarmory().get()),
luck: wrap(() => client.account().luck().get()),
Expand All @@ -42,7 +44,7 @@ function blob (parent) {
skiffs: wrap(() => client.account().skiffs().get()),
skins: wrap(() => client.account().skins().get()),
titles: wrap(() => client.account().titles().get()),
wallet: wrap(() => client.account().wallet().get())
wallet: wrap(() => client.account().wallet().get()),
}

return flow.parallel(requests).then(data => {
Expand Down
25 changes: 25 additions & 0 deletions src/endpoints/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ class AccountEndpoint extends AbstractEndpoint {
}
}

homestead () {
return {
decorations: () => new HomesteadDecorationsEndpoint(this),
glyphs: () => new HomesteadGlyphsEndpoint(this)
}
}

inventory () {
return new InventoryEndpoint(this)
}
Expand Down Expand Up @@ -287,6 +294,24 @@ class HomeNodesEndpoint extends AbstractEndpoint {
}
}

class HomesteadDecorationsEndpoint extends AbstractEndpoint {
constructor(client) {
super(client)
this.url = "/v2/account/homestead/decorations"
this.isAuthenticated = true
this.cacheTime = 5 * 60
}
}

class HomesteadGlyphsEndpoint extends AbstractEndpoint {
constructor(client) {
super(client)
this.url = "/v2/account/homestead/glyphs"
this.isAuthenticated = true
this.cacheTime = 5 * 60
}
}

class InventoryEndpoint extends AbstractEndpoint {
constructor (client) {
super(client)
Expand Down
45 changes: 45 additions & 0 deletions src/endpoints/homestead.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const AbstractEndpoint = require("../endpoint")

module.exports = class HomesteadEndpoint extends AbstractEndpoint {
decorations() {
return new DecorationsEndpoint(this)
}

glyphs() {
return new GlyphsEndpoint(this)
}
}

class DecorationsEndpoint extends AbstractEndpoint {
constructor(client) {
super(client)
this.url = "/v2/homestead/decorations"
this.isPaginated = true
this.isBulk = true
this.cacheTime = 24 * 60 * 60
}

categories() {
return new DecorationsCategoriesEndpoint(this)
}
}

class GlyphsEndpoint extends AbstractEndpoint {
constructor(client) {
super(client)
this.url = "/v2/homestead/glyphs"
this.isPaginated = true
this.isBulk = true
this.cacheTime = 24 * 60 * 60
}
}

class DecorationsCategoriesEndpoint extends AbstractEndpoint {
constructor(client) {
super(client)
this.url = "/v2/homestead/decorations/categories"
this.isPaginated = true
this.isBulk = true
this.cacheTime = 24 * 60 * 60
}
}
1 change: 1 addition & 0 deletions src/endpoints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
GlidersEndpoint: require('./gliders'),
GuildEndpoint: require('./guild'),
HomeEndpoint: require('./home'),
HomesteadEndpoint: require('./homestead'),
ItemsEndpoint: require('./items'),
ItemstatsEndpoint: require('./itemstats'),
JadebotsEndpoint: require('./jadebots'),
Expand Down
5 changes: 5 additions & 0 deletions tests/client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ describe('client', () => {
expect(endpoint.cats).not.toEqual(undefined)
})

it('can get the homestead endpoint', () => {
let endpoint = client.homestead()
expect(endpoint.decorations).not.toEqual(undefined)
})

it('can get the items endpoint', () => {
let endpoint = client.items()
expect(endpoint.url).toEqual('/v2/items')
Expand Down
8 changes: 8 additions & 0 deletions tests/endpoints/account-blob.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function mockClient (hasGuildPermission) {
cats: () => ({ get: () => _s([{ id: 1, hint: 'chicken' }]) }),
nodes: () => ({ get: () => _s(['quartz_node', 'airship_cargo']) })
}),
homestead: () => ({
decorations: () => ({ get: () => _s([{ id: 35, count: 50 }]) }),
glyphs: () => ({ get: () => _s(['volatility_harvesting', 'volatility_logging']) })
}),
inventory: () => ({ get: () => _s([{ id: 123, foo: 'bar' }]) }),
jadebots: () => ({ get: () => _s([1, 2, 3]) }),
legendaryarmory: () => ({ get: () => _s([{ id: 123, count: 1 }]) }),
Expand Down Expand Up @@ -105,6 +109,10 @@ const expectedResponse = {
cats: [{ id: 1, hint: 'chicken' }],
nodes: ['quartz_node', 'airship_cargo']
},
homestead: {
decorations: [{ id: 35, count: 50 }],
glyphs: ['volatility_harvesting', 'volatility_logging']
},
jadebots: [1, 2, 3],
legendaryarmory: [{ id: 123, count: 1 }],
luck: 123,
Expand Down
30 changes: 30 additions & 0 deletions tests/endpoints/account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,36 @@ describe('endpoints > account', () => {
expect(content).toEqual(['quartz_node', 'airship_cargo'])
})

it('test /v2/account/homestead/decorations', async () => {
endpoint = endpoint.homestead().decorations()

expect(endpoint.isPaginated).toEqual(false)
expect(endpoint.isBulk).toEqual(false)
expect(endpoint.isLocalized).toEqual(false)
expect(endpoint.isAuthenticated).toEqual(true)
expect(endpoint.cacheTime).not.toEqual(undefined)
expect(endpoint.url).toEqual('/v2/account/homestead/decorations')

fetchMock.addResponse([{ id: 35, count: 50 }])
let content = await endpoint.get()
expect(content).toEqual([{ id: 35, count: 50 }])
})

it('test /v2/account/homestead/glyphs', async () => {
endpoint = endpoint.homestead().glyphs()

expect(endpoint.isPaginated).toEqual(false)
expect(endpoint.isBulk).toEqual(false)
expect(endpoint.isLocalized).toEqual(false)
expect(endpoint.isAuthenticated).toEqual(true)
expect(endpoint.cacheTime).not.toEqual(undefined)
expect(endpoint.url).toEqual('/v2/account/homestead/glyphs')

fetchMock.addResponse(['volatility_harvesting', 'volatility_logging'])
let content = await endpoint.get()
expect(content).toEqual(['volatility_harvesting', 'volatility_logging'])
})

it('test /v2/account/jadebots', async () => {
endpoint = endpoint.jadebots()

Expand Down
71 changes: 71 additions & 0 deletions tests/endpoints/homestead.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* eslint-env jest */
const {mockClient, fetchMock} = require("../mocks/client.mock")
const Module = require("../../src/endpoints/homestead")

describe("endpoints > homestead", () => {
let endpoint
beforeEach(() => {
endpoint = new Module(mockClient)
fetchMock.reset()
})

it("test /v2/homestead/decorations", async () => {
endpoint = endpoint.decorations()

expect(endpoint.isPaginated).toEqual(true)
expect(endpoint.isBulk).toEqual(true)
expect(endpoint.isLocalized).toEqual(false)
expect(endpoint.isAuthenticated).toEqual(false)
expect(endpoint.cacheTime).not.toEqual(undefined)
expect(endpoint.url).toEqual("/v2/homestead/decorations")

fetchMock.addResponse({
id: 35,
name: "Kodan Cottage Wall",
description: "",
categories: [19, 1],
max_count: 250,
icon: "https://render.guildwars2.com/file/EBBA1865F40A0E6EFBCACA609271191E6E9CDDCF/3375022.png",
})

let content = await endpoint.get(35)
expect(content.name).toEqual("Kodan Cottage Wall")
})

it("test /v2/homestead/glyphs", async () => {
endpoint = endpoint.glyphs()

expect(endpoint.isPaginated).toEqual(true)
expect(endpoint.isBulk).toEqual(true)
expect(endpoint.isLocalized).toEqual(false)
expect(endpoint.isAuthenticated).toEqual(false)
expect(endpoint.cacheTime).not.toEqual(undefined)
expect(endpoint.url).toEqual("/v2/homestead/glyphs")

fetchMock.addResponse({
id: "volatility_harvesting",
})

let content = await endpoint.get("volatility_harvesting")
expect(content.id).toEqual("volatility_harvesting")
})

it("test /v2/homestead/decorations/categories", async () => {
endpoint = endpoint.decorations().categories()

expect(endpoint.isPaginated).toEqual(true)
expect(endpoint.isBulk).toEqual(true)
expect(endpoint.isLocalized).toEqual(false)
expect(endpoint.isAuthenticated).toEqual(false)
expect(endpoint.cacheTime).not.toEqual(undefined)
expect(endpoint.url).toEqual("/v2/homestead/decorations/categories")

fetchMock.addResponse({
id: 1,
name: "Architecture",
})

let content = await endpoint.get(1)
expect(content.name).toEqual("Architecture")
})
})

0 comments on commit fde423c

Please sign in to comment.