Update package name for easier use
This commit is contained in:
@ -31,8 +31,6 @@ export class Card implements ICard {
|
||||
types: string[];
|
||||
weaknesses: IWeakness[];
|
||||
|
||||
constructor() {}
|
||||
|
||||
resource(): string {
|
||||
return 'cards';
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
import { Client } from '../client';
|
||||
|
||||
export class Meta {
|
||||
constructor() {}
|
||||
|
||||
static allTypes(): Promise<string[]> {
|
||||
return Client.get('types');
|
||||
}
|
||||
|
||||
@ -15,8 +15,6 @@ export class Set implements ISet {
|
||||
totalCards: number;
|
||||
updatedAt: string;
|
||||
|
||||
constructor() {}
|
||||
|
||||
resource(): string {
|
||||
return 'sets';
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import * as axios from 'axios';
|
||||
import { PokemonTCG } from './sdk';
|
||||
import { API_URL, API_VERSION } from './sdk';
|
||||
import { IQuery } from './interfaces/query';
|
||||
|
||||
export class Client {
|
||||
static apiUrl: string = `${PokemonTCG.API_URL}/v${PokemonTCG.version}`;
|
||||
static apiUrl: string = `${API_URL}/v${API_VERSION}`;
|
||||
|
||||
static get(resource: string, params?: IQuery[] | string): Promise<any> {
|
||||
let url: string = `${this.apiUrl}/${resource}`;
|
||||
|
||||
45
src/index.ts
45
src/index.ts
@ -1,43 +1,2 @@
|
||||
import { Card as BaseCard } from './classes/card';
|
||||
import { Meta as BaseMeta } from './classes/meta';
|
||||
import { Set as BaseSet } from './classes/set';
|
||||
|
||||
export namespace PokemonTCG {
|
||||
export const Card = BaseCard;
|
||||
export type Card = BaseCard;
|
||||
|
||||
export const Meta = BaseMeta;
|
||||
export type Meta = BaseMeta;
|
||||
|
||||
export const Set = BaseSet;
|
||||
export type Set = BaseSet;
|
||||
|
||||
export interface IAbility {
|
||||
name: string;
|
||||
text: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface IAttack {
|
||||
convertedEnergyCost: string;
|
||||
cost: string[];
|
||||
damage: string;
|
||||
name: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface IQuery {
|
||||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
export interface IResistance {
|
||||
type: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface IWeakness {
|
||||
type: string;
|
||||
value: string;
|
||||
}
|
||||
}
|
||||
import * as PokemonTCG from './sdk';
|
||||
export { PokemonTCG };
|
||||
|
||||
@ -2,7 +2,6 @@ import { Client } from './client';
|
||||
import { Card } from "./classes/card";
|
||||
import { Set } from "./classes/set";
|
||||
import { IQuery } from './interfaces/query';
|
||||
import { AxiosResponse } from 'axios';
|
||||
|
||||
export class QueryBuilder {
|
||||
static all<T extends Card | Set>(type: (new () => T)): Promise<T[]> {
|
||||
|
||||
20
src/sdk.ts
20
src/sdk.ts
@ -1,4 +1,16 @@
|
||||
export namespace PokemonTCG {
|
||||
export const API_URL: string = 'https://api.pokemontcg.io';
|
||||
export const version: string = '1';
|
||||
}
|
||||
// Constants
|
||||
export const API_URL: string = 'https://api.pokemontcg.io';
|
||||
export const API_VERSION: string = '1';
|
||||
|
||||
// Classes
|
||||
export * from './classes/card';
|
||||
export * from './classes/set';
|
||||
export * from './classes/meta';
|
||||
|
||||
// Interfaces
|
||||
export * from './interfaces/ability';
|
||||
export * from './interfaces/attack';
|
||||
export * from './interfaces/card';
|
||||
export * from './interfaces/query';
|
||||
export * from './interfaces/resistance';
|
||||
export * from './interfaces/weakness';
|
||||
|
||||
Reference in New Issue
Block a user