All files / src index.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67                        106x             106x 106x                                                                                            
import { V1 } from './apis/v1';
import { V2 } from './apis/v2';
import { BetterRequired } from './types/utils';
import { SupportedLanguages } from './types/v1';
import { Schema } from './types/v2';
 
export class GuildWars2<V extends Schema = Schema.LATEST> {
  public v1: V1;
  public v2: V2<V>;
  public readonly config: GuildWars2.InternalConfig<V>;
 
  constructor(config?: GuildWars2.Config<V>) {
    this.config = {
      v: Schema.LATEST as V,
      lang: SupportedLanguages.ENGLISH,
      apply_corrections: true,
      ...config,
    };
 
    this.v1 = new V1(this.config);
    this.v2 = new V2(this.config);
  }
}
 
export namespace GuildWars2 {
  export type InternalConfig<V extends Schema> = BetterRequired<
    GuildWars2.Config<V>,
    'v' | 'lang' | 'apply_corrections'
  >;
 
  export type Config<V extends Schema> = Config.V1 & {
    /**
     * The default api key.
     * @default undefined
     */
    access_token?: string;
 
    /**
     * The default schema version.
     */
    v?: V;
 
    /**
     * Whether or not we should automatically fix invalid data.
     *
     * **Examples**
     *
     * {@link https://wiki.guildwars2.com/wiki/API:2/minis}
     *
     * @default true
     */
    apply_corrections?: boolean;
  };
 
  export namespace Config {
    export type V1 = {
      /**
       * Show localized texts in the specified language.
       * @default 'en'
       */
      lang?: SupportedLanguages;
    };
  }
}
 
export { Schema, SupportedLanguages };