Revert "Add v2 Migration"
This commit is contained in:
66
src/classes/card.ts
Normal file
66
src/classes/card.ts
Normal file
@ -0,0 +1,66 @@
|
||||
import { IAbility } from '../interfaces/ability';
|
||||
import { IAncientTrait } from '../interfaces/ancientTrait';
|
||||
import { IAttack } from '../interfaces/attack';
|
||||
import { ICard } from '../interfaces/card';
|
||||
import { ICardImage } from '../interfaces/image';
|
||||
import { ILegality } from '../interfaces/legality';
|
||||
import { IQuery } from '../interfaces/query';
|
||||
import { IResistance } from '../interfaces/resistance';
|
||||
import { ISet } from '../interfaces/set';
|
||||
import { ITCGPlayer } from '../interfaces/tcgplayer';
|
||||
import { IWeakness } from '../interfaces/weakness';
|
||||
import { QueryBuilder } from '../queryBuilder';
|
||||
|
||||
export class Card implements ICard {
|
||||
abilities: IAbility[];
|
||||
artist: string;
|
||||
ancientTrait?: IAncientTrait;
|
||||
attacks: IAttack[];
|
||||
convertedRetreatCost: number;
|
||||
evolvesFrom: string;
|
||||
hp: string;
|
||||
id: string;
|
||||
images: ICardImage;
|
||||
legalities: ILegality;
|
||||
name: string;
|
||||
nationalPokedexNumbers: number[];
|
||||
number: string;
|
||||
rarity: string;
|
||||
resistances: IResistance[];
|
||||
retreatCost: string[];
|
||||
rules: string[];
|
||||
set: ISet;
|
||||
subtypes: string[];
|
||||
supertype: string;
|
||||
tcgplayer: ITCGPlayer | undefined;
|
||||
types: string[];
|
||||
weaknesses: IWeakness[];
|
||||
|
||||
resource(): string {
|
||||
return 'cards';
|
||||
}
|
||||
|
||||
static async find(id: string): Promise<Card> {
|
||||
return QueryBuilder.find(this, id)
|
||||
.then(response => {
|
||||
return response;
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
}
|
||||
|
||||
static async all(): Promise<Card[]> {
|
||||
return QueryBuilder.all(this)
|
||||
.then(response => {
|
||||
return response;
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
}
|
||||
|
||||
static async where(params: IQuery[]): Promise<Card[]> {
|
||||
return QueryBuilder.where(this, params)
|
||||
.then(response => {
|
||||
return response;
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
}
|
||||
}
|
||||
19
src/classes/meta.ts
Normal file
19
src/classes/meta.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { Client } from '../client';
|
||||
|
||||
export class Meta {
|
||||
static async allTypes(): Promise<string[]> {
|
||||
return Client.get('types');
|
||||
}
|
||||
|
||||
static async allSubtypes(): Promise<string[]> {
|
||||
return Client.get('subtypes');
|
||||
}
|
||||
|
||||
static async allSupertypes(): Promise<string[]> {
|
||||
return Client.get('supertypes');
|
||||
}
|
||||
|
||||
static allRarities(): Promise<string[]> {
|
||||
return Client.get('rarities');
|
||||
}
|
||||
}
|
||||
46
src/classes/set.ts
Normal file
46
src/classes/set.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import { ISet } from '../interfaces/set';
|
||||
import { IQuery } from '../interfaces/query';
|
||||
import { QueryBuilder } from '../queryBuilder';
|
||||
import { ILegality } from '../interfaces/legality';
|
||||
import { ISetImage } from '../interfaces/image';
|
||||
|
||||
export class Set implements ISet {
|
||||
id: string;
|
||||
images: ISetImage;
|
||||
legalities: ILegality;
|
||||
name: string;
|
||||
printedTotal: number;
|
||||
ptcgoCode: string;
|
||||
releaseDate: string;
|
||||
series: string;
|
||||
total: number;
|
||||
updatedAt: string;
|
||||
|
||||
resource(): string {
|
||||
return 'sets';
|
||||
}
|
||||
|
||||
static async find(id: string): Promise<Set> {
|
||||
return QueryBuilder.find(this, id)
|
||||
.then(response => {
|
||||
return response;
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
}
|
||||
|
||||
static async all(): Promise<Set[]> {
|
||||
return QueryBuilder.all(this)
|
||||
.then(response => {
|
||||
return response;
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
}
|
||||
|
||||
static async where(params: IQuery[]): Promise<Set[]> {
|
||||
return QueryBuilder.where(this, params)
|
||||
.then(response => {
|
||||
return response;
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
}
|
||||
}
|
||||
@ -1,71 +1,37 @@
|
||||
import * as axios from 'axios';
|
||||
import { Query } from './interfaces/query';
|
||||
import { API_URL, API_VERSION } from './sdk';
|
||||
import { IQuery } from './interfaces/query';
|
||||
|
||||
export class Client {
|
||||
private readonly POKEMONTCG_API_BASE_URL: string =
|
||||
'https://api.pokemontcg.io';
|
||||
private readonly POKEMONTCG_API_VERSION: string = '2';
|
||||
private readonly POKEMONTCG_API_URL: string = `${this.POKEMONTCG_API_BASE_URL}/v${this.POKEMONTCG_API_VERSION}`;
|
||||
private readonly POKEMONTCG_API_KEY?: string =
|
||||
process.env.POKEMONTCG_API_KEY;
|
||||
static apiUrl: string = `${API_URL}/v${API_VERSION}`;
|
||||
|
||||
private static instance: Client;
|
||||
static async get(resource: string, params?: IQuery[] | string): Promise<any> {
|
||||
let url: string = `${this.apiUrl}/${resource}`;
|
||||
const config: axios.AxiosRequestConfig = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
|
||||
private constructor() {}
|
||||
if(typeof params === 'string') url += `/${params}`;
|
||||
else url += `?${this.paramsToQuery(params)}`;
|
||||
|
||||
public static getInstance(): Client {
|
||||
if (!Client.instance) {
|
||||
Client.instance = new Client();
|
||||
}
|
||||
return axios.default.get<any>(url, config)
|
||||
.then(response => {
|
||||
return response.data[Object.keys(response.data)[0]];
|
||||
})
|
||||
.catch(error => Promise.reject(error));
|
||||
}
|
||||
|
||||
return Client.instance;
|
||||
private static paramsToQuery(params?: IQuery[]): string {
|
||||
let query: string = '';
|
||||
|
||||
if (params) {
|
||||
params.map((q: IQuery) => {
|
||||
query += `${q.name}=${encodeURIComponent(q.value.toString())}`.concat('&');
|
||||
});
|
||||
}
|
||||
|
||||
async get<T>(resource: string, params?: Query[] | string): Promise<T> {
|
||||
let url = `${this.POKEMONTCG_API_URL}/${resource}`;
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
|
||||
if (this.POKEMONTCG_API_KEY) {
|
||||
headers['X-Api-Key'] = this.POKEMONTCG_API_KEY;
|
||||
}
|
||||
|
||||
const config: axios.AxiosRequestConfig = {
|
||||
headers,
|
||||
};
|
||||
|
||||
if (typeof params === 'string') {
|
||||
if (
|
||||
params.toLowerCase().includes('page') ||
|
||||
params.toLowerCase().includes('order')
|
||||
)
|
||||
url += `?${params}`;
|
||||
else url += `/${params}`;
|
||||
} else if (params) url += `?q=${this.paramsToQuery(params)}`;
|
||||
|
||||
return axios.default
|
||||
.get<T>(url, config)
|
||||
.then((response) => {
|
||||
return response.data[Object.keys(response.data)[0]];
|
||||
})
|
||||
.catch((error) => Promise.reject(error));
|
||||
}
|
||||
|
||||
private paramsToQuery(params: Query[]): string {
|
||||
let query = '';
|
||||
const paramsLength: number = params.length;
|
||||
|
||||
params.map((q: Query, i: number) => {
|
||||
if (paramsLength === i + 1) {
|
||||
query += `${q.name}:${encodeURIComponent(q.value.toString())}`;
|
||||
} else {
|
||||
query += `${q.name}:${encodeURIComponent(
|
||||
q.value.toString()
|
||||
)}`.concat('&');
|
||||
}
|
||||
});
|
||||
|
||||
return query;
|
||||
}
|
||||
}
|
||||
return query;
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
export enum Parameter {
|
||||
Query = 'q',
|
||||
Page = 'page',
|
||||
PageSize = 'pageSize',
|
||||
Order = 'orderBy',
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
export enum Rarity {
|
||||
AmazingRare = 'Amazing Rare',
|
||||
Common = 'Common',
|
||||
Legend = 'LEGEND',
|
||||
Promo = 'Promo',
|
||||
Rare = 'Rare',
|
||||
RareAce = 'Rare ACE',
|
||||
RareBreak = 'Rare BREAK',
|
||||
RareHolo = 'Rare Holo',
|
||||
RareHoloEX = 'Rare Holo EX',
|
||||
RareHoloGX = 'Rare Holo GX',
|
||||
RareHoloLVX = 'Rare Holo LV.X',
|
||||
RareHoloStar = 'Rare Holo Star',
|
||||
RareHoloV = 'Rare Holo V',
|
||||
RareHoloVMAX = 'Rare Holo VMAX',
|
||||
RarePrime = 'Rare Prime',
|
||||
RarePrimeStar = 'Rare Prism Star',
|
||||
RareRainbow = 'Rare Rainbow',
|
||||
RareSecret = 'Rare Secret',
|
||||
RareShining = 'Rare Shining',
|
||||
RareShiny = 'Rare Shiny',
|
||||
RareShinyGX = 'Rare Shiny GX',
|
||||
RareUltra = 'Rare Ultra',
|
||||
Uncommon = 'Uncommon',
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
export enum Subtype {
|
||||
Break = 'BREAK',
|
||||
Baby = 'Baby',
|
||||
Basic = 'Basic',
|
||||
EX = 'EX',
|
||||
GX = 'GX',
|
||||
GoldenrodGameCorner = 'Goldenrod Game Corner',
|
||||
Item = 'Item',
|
||||
Legend = 'LEGEND',
|
||||
LevelUp = 'Level-Up',
|
||||
Mega = 'MEGA',
|
||||
PokemonTool = 'Pokémon Tool',
|
||||
PokemonToolF = 'Pokémon Tool F',
|
||||
Restored = 'Restored',
|
||||
RocketsSecretMachine = "Rocket's Secret Machine",
|
||||
Special = 'Special',
|
||||
Stadium = 'Stadium',
|
||||
StageOne = 'Stage 1',
|
||||
StageTwo = 'Stage 2',
|
||||
Supporter = 'Supporter',
|
||||
TagTeam = 'TAG TEAM',
|
||||
TechnicalMachine = 'Technical Machine',
|
||||
V = 'V',
|
||||
VMax = 'VMAX',
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
export enum Supertype {
|
||||
Energy = 'Energy',
|
||||
Pokemon = 'Pokémon',
|
||||
Trainer = 'Trainer',
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
export enum Type {
|
||||
Colorless = 'Colorless',
|
||||
Darkness = 'Darkness',
|
||||
Dragon = 'Dragon',
|
||||
Fairy = 'Fairy',
|
||||
Fighting = 'Fighting',
|
||||
Fire = 'Fire',
|
||||
Grass = 'Grass',
|
||||
Lightening = 'Lightning',
|
||||
Metal = 'Metal',
|
||||
Psychic = 'Psychic',
|
||||
Water = 'Water',
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
export interface Ability {
|
||||
name: string;
|
||||
text: string;
|
||||
type: string;
|
||||
}
|
||||
export interface IAbility {
|
||||
name: string;
|
||||
text: string;
|
||||
type: string;
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
export interface AncientTrait {
|
||||
name: string;
|
||||
text: string;
|
||||
}
|
||||
export interface IAncientTrait {
|
||||
name: string;
|
||||
text: string;
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
export interface Attack {
|
||||
convertedEnergyCost: number;
|
||||
cost: string[];
|
||||
damage: string;
|
||||
name: string;
|
||||
text: string;
|
||||
}
|
||||
export interface IAttack {
|
||||
convertedEnergyCost: number;
|
||||
cost: string[];
|
||||
damage: string;
|
||||
name: string;
|
||||
text: string;
|
||||
}
|
||||
@ -1,41 +1,36 @@
|
||||
import { Ability } from './ability';
|
||||
import { AncientTrait } from './ancientTrait';
|
||||
import { Attack } from './attack';
|
||||
import { Resistance, Weakness } from './stats';
|
||||
import { CardImage } from './image';
|
||||
import { IAbility } from '../interfaces/ability';
|
||||
import { IAncientTrait } from './ancientTrait';
|
||||
import { IAttack } from '../interfaces/attack';
|
||||
import { IResistance } from '../interfaces/resistance';
|
||||
import { IWeakness } from '../interfaces/weakness';
|
||||
import { ICardImage } from './image';
|
||||
import { ILegality } from './legality';
|
||||
import { Set } from './set';
|
||||
import { TCGPlayer } from './tcgplayer';
|
||||
import { ISet } from './set';
|
||||
import { ITCGPlayer } from './tcgplayer';
|
||||
|
||||
import { Type } from '../enums/type';
|
||||
import { Supertype } from '../enums/supertype';
|
||||
import { Subtype } from '../enums/subtype';
|
||||
import { Rarity } from '../enums/rarity';
|
||||
|
||||
export interface Card {
|
||||
id: string;
|
||||
name: string;
|
||||
supertype: Supertype;
|
||||
subtypes: Subtype[];
|
||||
hp?: string;
|
||||
types?: Type[];
|
||||
evolesFrom?: string;
|
||||
evolvesTo?: string[];
|
||||
rules?: string[];
|
||||
ancientTrait?: AncientTrait;
|
||||
abilities?: Ability[];
|
||||
attacks?: Attack[];
|
||||
weaknesses?: Weakness[];
|
||||
resistances?: Resistance[];
|
||||
retreatCost?: string[];
|
||||
convertedRetreatCost?: number;
|
||||
set: Set;
|
||||
number: string;
|
||||
artist?: string;
|
||||
rarity: Rarity;
|
||||
flavorText?: string;
|
||||
nationalPokedexNumbers?: number[];
|
||||
legalities: ILegality;
|
||||
images: CardImage;
|
||||
tcgplayer?: TCGPlayer;
|
||||
}
|
||||
export interface ICard {
|
||||
abilities: IAbility[];
|
||||
artist: string;
|
||||
ancientTrait?: IAncientTrait;
|
||||
attacks: IAttack[];
|
||||
convertedRetreatCost: number;
|
||||
evolvesFrom: string;
|
||||
flavorText: string;
|
||||
hp: string;
|
||||
id: string;
|
||||
images: ICardImage;
|
||||
legalities: ILegality;
|
||||
name: string;
|
||||
nationalPokedexNumbers: number[];
|
||||
number: string;
|
||||
rarity: string;
|
||||
resistances: IResistance[];
|
||||
retreatCost: string[];
|
||||
rules: string[];
|
||||
set: ISet;
|
||||
subtypes: string[];
|
||||
supertype: string;
|
||||
tcgplayer: ITCGPlayer | undefined;
|
||||
types: string[];
|
||||
weaknesses: IWeakness[];
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
export interface SetImage {
|
||||
symbol: string;
|
||||
logo: string;
|
||||
export interface ISetImage {
|
||||
symbol: string;
|
||||
logo: string;
|
||||
}
|
||||
|
||||
export interface CardImage {
|
||||
small: string;
|
||||
large: string;
|
||||
}
|
||||
export interface ICardImage {
|
||||
small: string;
|
||||
large: string;
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
export enum Legality {
|
||||
Legal = 'Legal',
|
||||
Banned = 'Banned',
|
||||
LEGAL = 'Legal',
|
||||
BANNED = 'Banned',
|
||||
}
|
||||
|
||||
export interface ILegality {
|
||||
expanded?: Legality;
|
||||
standard?: Legality;
|
||||
unlimited?: Legality;
|
||||
}
|
||||
expanded: Legality | undefined
|
||||
standard: Legality | undefined
|
||||
unlimited: Legality | undefined
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
export interface Query {
|
||||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
export interface IQuery {
|
||||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
4
src/interfaces/resistance.ts
Normal file
4
src/interfaces/resistance.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export interface IResistance {
|
||||
type: string;
|
||||
value: string;
|
||||
}
|
||||
@ -1,15 +1,15 @@
|
||||
import { SetImage } from './image';
|
||||
import { ILegality } from './legality';
|
||||
import { ISetImage } from "./image";
|
||||
import { ILegality } from "./legality";
|
||||
|
||||
export interface Set {
|
||||
id: string;
|
||||
name: string;
|
||||
series: string;
|
||||
printedTotal: number;
|
||||
total: number;
|
||||
legalities: ILegality;
|
||||
ptcgoCode: string;
|
||||
releaseDate: string;
|
||||
updatedAt: string;
|
||||
images: SetImage;
|
||||
}
|
||||
export interface ISet {
|
||||
id: string;
|
||||
images: ISetImage;
|
||||
legalities: ILegality;
|
||||
name: string;
|
||||
printedTotal: number;
|
||||
ptcgoCode: string;
|
||||
releaseDate: string;
|
||||
series: string;
|
||||
total: number;
|
||||
updatedAt: string;
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
interface Stats {
|
||||
type: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Resistance extends Stats {}
|
||||
|
||||
export interface Weakness extends Stats {}
|
||||
@ -1,17 +1,17 @@
|
||||
export interface TCGPlayer {
|
||||
url: string;
|
||||
updatedAt: string;
|
||||
prices: {
|
||||
normal?: Price;
|
||||
holofoil?: Price;
|
||||
reverseHolofoil?: Price;
|
||||
};
|
||||
export interface ITCGPlayer {
|
||||
url: string;
|
||||
updatedAt: string;
|
||||
prices: {
|
||||
normal: IPrice | undefined;
|
||||
holofoil: IPrice | undefined;
|
||||
reverseHolofoil: IPrice | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export interface Price {
|
||||
low: number | null;
|
||||
mid: number | null;
|
||||
high: number | null;
|
||||
market: number | null;
|
||||
directLow: number | null;
|
||||
}
|
||||
export interface IPrice {
|
||||
low: number | null
|
||||
mid: number | null
|
||||
high: number | null
|
||||
market: number | null
|
||||
directLow: number | null
|
||||
}
|
||||
4
src/interfaces/weakness.ts
Normal file
4
src/interfaces/weakness.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export interface IWeakness {
|
||||
type: string;
|
||||
value: string;
|
||||
}
|
||||
28
src/queryBuilder.ts
Normal file
28
src/queryBuilder.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Client } from './client';
|
||||
import { Card } from './classes/card';
|
||||
import { Set } from './classes/set';
|
||||
import { IQuery } from './interfaces/query';
|
||||
|
||||
export class QueryBuilder {
|
||||
static all<T extends Card | Set>(type: {new (): T}): Promise<T[]> {
|
||||
const t = new type();
|
||||
const params: IQuery[] = [{
|
||||
name: 'pageSize',
|
||||
value: 250,
|
||||
}];
|
||||
|
||||
return Client.get(t.resource(), params);
|
||||
}
|
||||
|
||||
static find<T extends Card | Set>(type: {new (): T}, id: string): Promise<T> {
|
||||
const t = new type();
|
||||
|
||||
return Client.get(t.resource(), id);
|
||||
}
|
||||
|
||||
static where<T extends Card | Set>(type: {new (): T}, params: IQuery[]): Promise<T[]> {
|
||||
const t = new type();
|
||||
|
||||
return Client.get(t.resource(), params);
|
||||
}
|
||||
}
|
||||
23
src/sdk.ts
23
src/sdk.ts
@ -1,17 +1,16 @@
|
||||
// Constants
|
||||
export const API_URL: string = 'https://api.pokemontcg.io';
|
||||
export const API_VERSION: string = '2';
|
||||
|
||||
// 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/stats';
|
||||
|
||||
// Enums
|
||||
export * from './enums/type';
|
||||
export * from './enums/supertype';
|
||||
export * from './enums/subtype';
|
||||
export * from './enums/rarity';
|
||||
export * from './enums/parameter';
|
||||
|
||||
// Services
|
||||
export * from './services/cardService';
|
||||
export * from './services/setService';
|
||||
export * from './interfaces/resistance';
|
||||
export * from './interfaces/weakness';
|
||||
|
||||
@ -1,55 +0,0 @@
|
||||
import { Query } from '../interfaces/query';
|
||||
import { Card } from '../interfaces/card';
|
||||
import { Type } from '../enums/type';
|
||||
import { Supertype } from '../enums/supertype';
|
||||
import { Subtype } from '../enums/subtype';
|
||||
import { Rarity } from '../enums/rarity';
|
||||
import { Client } from '../client';
|
||||
|
||||
export async function findCardByID(id: string): Promise<Card> {
|
||||
const client: Client = Client.getInstance();
|
||||
const response: Card = await client.get<Card>('cards', id);
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function findCardsByQueries(params: Query[]): Promise<Card[]> {
|
||||
const client: Client = Client.getInstance();
|
||||
const response: Card[] = await client.get<Card[]>('cards', params);
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function getAllCards(): Promise<Card[]> {
|
||||
const param = 'pageSize:250';
|
||||
|
||||
const client: Client = Client.getInstance();
|
||||
const response: Card[] = await client.get<Card[]>('cards', param);
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function getTypes(): Promise<Type[]> {
|
||||
const client: Client = Client.getInstance();
|
||||
|
||||
const response: Type[] = await client.get<Type[]>('types');
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function getSupertypes(): Promise<Supertype[]> {
|
||||
const client: Client = Client.getInstance();
|
||||
|
||||
const response: Supertype[] = await client.get<Supertype[]>('supertypes');
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function getSubtypes(): Promise<Subtype[]> {
|
||||
const client: Client = Client.getInstance();
|
||||
|
||||
const response: Subtype[] = await client.get<Subtype[]>('subtypes');
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function getRarities(): Promise<Rarity[]> {
|
||||
const client: Client = Client.getInstance();
|
||||
|
||||
const response: Rarity[] = await client.get<Rarity[]>('rarities');
|
||||
return response;
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
import { Query } from '../interfaces/query';
|
||||
import { Set } from '../interfaces/set';
|
||||
import { Client } from '../client';
|
||||
|
||||
export async function findSetByID(id: string): Promise<Set> {
|
||||
const client: Client = Client.getInstance();
|
||||
const response: Set = await client.get<Set>('sets', id);
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function findSetsByQueries(params: Query[]): Promise<Set[]> {
|
||||
const client: Client = Client.getInstance();
|
||||
const response: Set[] = await client.get<Set[]>('sets', params);
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function getAllSets(): Promise<Set[]> {
|
||||
const param = 'pageSize:250';
|
||||
|
||||
const client: Client = Client.getInstance();
|
||||
const response: Set[] = await client.get<Set[]>('sets', param);
|
||||
return response;
|
||||
}
|
||||
Reference in New Issue
Block a user