Skip to content

Commit 4689264

Browse files
committed
feat: support for pvp team and schema updates
1 parent ff374b3 commit 4689264

File tree

9 files changed

+40
-14
lines changed

9 files changed

+40
-14
lines changed

index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
// Public classes.
2-
export * from './src/model/index';
32
export * from './src/index';

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export { XivapiClientModule, XIVAPI_KEY } from './xivapi-client.module';
22
export { XivapiService } from './xivapi.service';
3+
export * from './model/index';
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { CharacterSearchResultRow } from './character-search-result-row';
2+
import { Pagination } from './pagination';
23

34
export interface CharacterSearchResult {
4-
Characters: CharacterSearchResultRow[];
5+
Results: CharacterSearchResultRow[];
56

6-
// TODO change this for normalized pagination
7-
PageCurrent: number;
8-
PageNext: number;
9-
PagePrevious: number;
10-
PageTotal: number;
11-
Total: number;
7+
Pagination: Pagination;
128
}

src/model/schema/character/character-response.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Character } from './character';
2+
import { PvpTeam } from '../pvp-team';
23

34
export interface CharacterResponse {
45
// TODO
@@ -15,6 +16,5 @@ export interface CharacterResponse {
1516
// TODO
1617
Info: any;
1718

18-
// TODO
19-
PvPTeam: any;
19+
PvPTeam: PvpTeam;
2020
}

src/model/schema/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './character/index';
2+
export * from './pvp-team/index';

src/model/schema/pvp-team/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './pvp-team';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface PvpTeamMember {
2+
Avatar: string;
3+
FeastMatches: number;
4+
ID: number;
5+
Name: string;
6+
Rank: string;
7+
RankIcon: string;
8+
Server: string;
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { PvpTeamMember } from './pvp-team-member';
2+
3+
export interface PvpTeam {
4+
Crest: [string, string, string];
5+
ID: string;
6+
Members: PvpTeamMember[];
7+
Name: string;
8+
Server: string;
9+
}

src/xivapi.service.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { HttpClient, HttpParams } from '@angular/common/http';
33
import { Observable } from 'rxjs';
44
import {
55
CharacterSearchResult,
6+
PvpTeam,
67
XivapiCharacterOptions,
78
XivapiEndpoint,
89
XivapiList,
@@ -31,8 +32,8 @@ export class XivapiService {
3132
* @param id The id of the resource for the request.
3233
* @param options The options of the request, optional.
3334
*/
34-
public get(endpoint: XivapiEndpoint, id: number, options?: XivapiRequestOptions): Observable<any> {
35-
return this.request<any>(`${XivapiService.API_BASE_URL}/${endpoint}/${id}`, options);
35+
public get<T = any>(endpoint: XivapiEndpoint, id: number, options?: XivapiRequestOptions): Observable<T> {
36+
return this.request<T>(`${XivapiService.API_BASE_URL}/${endpoint}/${id}`, options);
3637
}
3738

3839
/**
@@ -41,8 +42,8 @@ export class XivapiService {
4142
* @param endpoint The endpoint to use for the request.
4243
* @param options The options of the request, optional.
4344
*/
44-
public getList(endpoint: XivapiEndpoint, options?: XivapiRequestOptions): Observable<XivapiList<any>> {
45-
return this.request<XivapiList<any>>(`${XivapiService.API_BASE_URL}/${endpoint}`, options);
45+
public getList<T = any>(endpoint: XivapiEndpoint, options?: XivapiRequestOptions): Observable<XivapiList<T>> {
46+
return this.request<XivapiList<T>>(`${XivapiService.API_BASE_URL}/${endpoint}`, options);
4647
}
4748

4849
/**
@@ -138,6 +139,15 @@ export class XivapiService {
138139
return this.request<any>(`${XivapiService.API_BASE_URL}/Linkshell/${lodestoneId}${details ? '/' + details : ''}`, options);
139140
}
140141

142+
/**
143+
* Gets a PvP team based on its lodestone id (string)
144+
*
145+
* @param id the id of the team to get.
146+
*/
147+
public getPvPTeam(id: string): Observable<PvpTeam> {
148+
return this.request<PvpTeam>(`${XivapiService.API_BASE_URL}/PvPTeam/${id}`);
149+
}
150+
141151
/**
142152
* Gets the list of patches using the /PatchList endpoint.
143153
* @param options Options of the request.

0 commit comments

Comments
 (0)