Skip to content

Commit 5b49a51

Browse files
committed
Add CWL
1 parent b70da45 commit 5b49a51

File tree

7 files changed

+71
-3
lines changed

7 files changed

+71
-3
lines changed

XIVAPI.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const resources = require('./resources/'),
44
Character = require('./lib/character'),
55
FreeCompany = require('./lib/freecompany'),
66
Linkshell = require('./lib/linkshell'),
7+
CWL = require('./lib/cwl'),
78
PvPTeam = require('./lib/pvpteam')
89

910
class XIVAPI {
@@ -49,6 +50,7 @@ See how in https://github.com/xivapi/xivapi-js/releases/tag/v0.1.3.\n\
4950
this.character = new Character(this)
5051
this.freecompany = new FreeCompany(this)
5152
this.linkshell = new Linkshell(this)
53+
this.cwl = new CWL(this)
5254
this.pvpteam = new PvPTeam(this)
5355
}
5456
}

lib/cwl.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// https://xivapi.com/docs/Linkshell
2+
const Lib = require('./Lib')
3+
4+
class CWL extends Lib {
5+
constructor(parent) {
6+
super(parent)
7+
}
8+
9+
/*
10+
{
11+
server string optional
12+
page int optional
13+
}
14+
*/
15+
async search(name, params={}) {
16+
if(typeof(name) === 'undefined')
17+
throw this.throwError('cwl.search()','a name')
18+
return this.req('/linkshell/crossworld/search', Object.assign(params, {name}))
19+
}
20+
21+
async get(id) {
22+
if(typeof(id) === 'undefined')
23+
throw this.throwError('cwl.get()', 'an ID')
24+
return this.req(`/linkshell/crossworld/${id}`)
25+
}
26+
}
27+
28+
module.exports = CWL

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xivapi/js",
3-
"version": "0.4.3",
3+
"version": "0.4.4",
44
"description": "A Node.JS wrapper for xivapi.com",
55
"main": "XIVAPI.js",
66
"directories": {

typings/index.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import {
1010
LinkshellGetResult,
1111
LinkshellSearchParams,
1212
LinkshellSearchResult,
13+
CWLGetResult,
14+
CWLSearchParams,
15+
CWLSearchResult,
1316
PvPTeamGetResult,
1417
PvPTeamSearchParams,
1518
PvPTeamSearchResult,
@@ -194,6 +197,16 @@ declare module "@xivapi/js" {
194197
get: (id: string | number) => Promise<LinkshellGetResult>;
195198
};
196199

200+
/**
201+
* Search and retrieve CWL data from The Lodestone.
202+
* @since 0.4.4
203+
* @see https://xivapi.com/docs/Linkshell
204+
*/
205+
public cwl: {
206+
search: (name: string, params?: CWLSearchParams) => Promise<CWLSearchResult>;
207+
get: (id: string | number) => Promise<CWLGetResult>;
208+
};
209+
197210
/**
198211
* Search and retrieve PVP Team data from The Lodestone.
199212
* @since 0.4.2

typings/utils/cwl.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { CharacterSearchResult } from "./character";
2+
import { SearchParams, SearchResult } from "./search";
3+
4+
export interface CWLSearchParams extends SearchParams {}
5+
6+
export interface CWLSearchResult extends SearchResult {
7+
Results: {
8+
Crest: string[];
9+
ID: string;
10+
Name: string;
11+
Server: string;
12+
}[];
13+
}
14+
15+
export interface CWLGetResult {
16+
CWL: {
17+
ID: string;
18+
Pagination: SearchResult["Pagination"];
19+
Profile: {
20+
Name: string;
21+
};
22+
Results: CharacterSearchResult["Results"];
23+
};
24+
}

typings/utils/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from "./character";
22
export * from "./freecompany";
33
export * from "./linkshell";
4+
export * from "./cwl";
45
export * from "./pvpteam";
56
export * from "./search";

0 commit comments

Comments
 (0)