Skip to content
Permalink
Browse files

feat: support for /Character endpoint

  • Loading branch information
Supamiu committed Aug 10, 2018
1 parent f54bfc2 commit 238c60425797e568ba55ceb4b2619f9a7cee9923
@@ -8,3 +8,4 @@ export { XivapiOptions } from './xivapi-options';
export { XivapiRequestOptions } from './xivapi-request-options';
export { XivapiSearchFilter } from './xivapi-search-filter';
export { XivapiSearchOptions } from './xivapi-search-options';
export * from './schema/index';
@@ -0,0 +1,24 @@
import { Character } from './character';

export interface CharacterResponse {
Payload: Character;
/**
* State | Number | Details
* --- | --- | ---
* STATE_ADDING | 1 | This state is returned when the character does not exist on the API
* and needs adding (the first ever request and sub-sequent requests until the character is added).
* The Payload should be empty if this state is provided.
* You are advised to inform your audience that a character add request has been performed.
* It should take 2 minutes or less to add your character.
*
* STATE_CACHED | 2 | This state is returned when the character exists in the system and you're being provided a cached response.
* The Payload will contain the character information which will include useful information such as LastUpdated
* which you can use to base on if a character update request is required
* STATE_NOT_FOUND | 3 | This state is returned when a character does not exist on The Lodestone.
* If a character is attempted to be added but the system does not find it then it will be registered as not found.
* The Payload will return empty. Characters in this state are checked every 24 hours,
* if the character continues to not be found after several tries then this entry will be deleted.
* You can also request a deletion of this entry via the /Delete endpoint.
*/
State: 1 | 2 | 3;
}
@@ -0,0 +1,5 @@
export interface CharacterVerification {
ID: number;
VerificationToken: string;
VerificationTokenPass: boolean;
}
@@ -0,0 +1,31 @@
import { ClassJob } from './class-job';
import { GearSet } from './gear-set';
import { GrandCompany } from './grand-company';

export interface Character {
ActiveClassJob: ClassJob;
Added: number;
Avatar: string;
Bio: string;
ClassJobs: { [index: string]: ClassJob };
FreeCompanyId: number;
GearSet: GearSet;
Gender: 1 | 2;
GrandCompany: GrandCompany;
GuardianDeity: number;
ID: number;
Minions: number[];
Mounts: number[];
Name: string;
Nameday: string;
Portrait: string;
PvPTeam: null;
Race: number;
Server: string;
Title: number;
Town: number;
Tribe: number;
Updated: number;
VerificationToken: string;
VerificationTokenPass: boolean;
}
@@ -0,0 +1,8 @@
export interface ClassJob {
ClassID: number;
ExpLevel: number;
ExpLevelMax: number;
ExpLevelTogo: number;
JobID: number;
Level: number;
}
@@ -0,0 +1,17 @@
import { GearPiece } from './gear-piece';

export interface GearDetails {
Body: GearPiece;
Bracelets: GearPiece;
Earrings: GearPiece;
Feet: GearPiece;
Hands: GearPiece;
Head: GearPiece;
Legs: GearPiece;
MainHand: GearPiece;
Necklace: GearPiece;
Ring1: GearPiece;
Ring2: GearPiece;
SoulCrystal: GearPiece;
Waist: GearPiece;
}
@@ -0,0 +1,7 @@
export interface GearPiece {
Creator: any; // Typed to any for now as I don't have more details, didn't have this information on my char.
Dye: any; // Typed to any for now as I don't have more details, didn't have this information on my char.
ID: number;
Materia: any[]; // Typed to any for now as I don't have more details, didn't have this information on my char.
Mirage: any; // Typed to any for now as I don't have more details, didn't have this information on my char.
}
@@ -0,0 +1,10 @@
import { GearDetails } from './gear-details';

export interface GearSet {
Attributes: { [index: string]: number };
ClassID: number;
Gear: GearDetails;
GearKey: string;
JobID: number;
Level: number;
}
@@ -0,0 +1,4 @@
export interface GrandCompany {
NameID: number;
RankID: number;
}
@@ -0,0 +1,8 @@
export * from './character';
export * from './character-response';
export * from './character-verification';
export * from './class-job';
export * from './gear-details';
export * from './gear-piece';
export * from './gear-set';
export * from './grand-company';
@@ -0,0 +1 @@
export * from './character/index';
@@ -3,6 +3,8 @@ import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { XivapiCharacterOptions, XivapiEndpoint, XivapiList, XivapiOptions, XivapiRequestOptions, XivapiSearchOptions } from './model';
import { XIVAPI_KEY } from './xivapi-client.module';
import { CharacterResponse } from './model/schema/character/character-response';
import { CharacterVerification } from './model/schema/character/character-verification';

@Injectable()
export class XivapiService {
@@ -60,10 +62,20 @@ export class XivapiService {
* @param details Specific details you want to get.
*/
public getCharacter(lodestoneId: number, options?: XivapiCharacterOptions,
details?: 'friends' | 'achievements' | 'gearsets' | 'record'): Observable<any> {
details?: 'Friends' | 'Achievements' | 'Gearsets' | 'Record' | 'FreeCompany'): Observable<CharacterResponse> {
return this.request<any>(`${XivapiService.API_BASE_URL}/Character/${lodestoneId}${details ? '/' + details : ''}`, options);
}

/**
* Gets character verification informations based on lodestoneId.
*
* @param lodestoneId LodestoneID of the character to get.
* @param options Options of the request.
*/
public verifyCharacter(lodestoneId: number, options?: XivapiCharacterOptions): Observable<CharacterVerification> {
return this.request<any>(`${XivapiService.API_BASE_URL}/Character/${lodestoneId}/Verification`, options);
}


/**
* Gets a free company using the /FreeCompany endpoint.

0 comments on commit 238c604

Please sign in to comment.
You can’t perform that action at this time.