Update package

This commit is contained in:
CptSpaceToaster
2019-07-06 16:59:29 -04:00
parent 415e3f1f94
commit 26dce235a6
13 changed files with 478 additions and 406 deletions

View File

@ -1,24 +1,21 @@
import { Client } from './client';
import { Card } from "./classes/card";
import { Set } from "./classes/set";
import { Type } from "./classes/type";
import { SubType } from "./classes/subType";
import { SuperType } from "./classes/superType";
import { IQuery } from './interfaces/query';
import { AxiosResponse } from 'axios';
export class QueryBuilder {
static all<T extends Card | Set | Type | SuperType | SubType>(type: (new() => T)): Promise<T[]> {
static all<T extends Card | Set>(type: (new() => T)): Promise<T[]> {
let t = new type();
let params: IQuery[] = [{
name: 'pageSize',
value: 1000
}];
return this.returnResponse(t.resource(), params);
return this.returnResponse(t.resource(), params);
}
static find<T extends Card | Set | Type | SuperType | SubType>(type: (new() => T), id: string): Promise<T> {
static find<T extends Card | Set>(type: (new() => T), id: string): Promise<T> {
let t = new type();
let params: IQuery[] = [{
name: 'id',
@ -28,13 +25,13 @@ export class QueryBuilder {
return this.returnResponse(t.resource(), params, true);
}
static where<T extends Card | Set | Type | SuperType | SubType>(type: (new() => T), params: IQuery[]): Promise<T[]> {
static where<T extends Card | Set>(type: (new() => T), params: IQuery[]): Promise<T[]> {
let t = new type();
return this.returnResponse(t.resource(), params);
}
private static returnResponse(resource: string, params: IQuery[], single?: boolean): Promise<any> {
public static returnResponse(resource: string, params: IQuery[], single?: boolean): Promise<any> {
return Client.get(resource, params)
.then(response => {
if (single) {