Merge pull request #7 from CptSpaceToaster/master
Update package for easier use
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
node_modules
|
||||
dist
|
||||
dist
|
||||
*.tgz
|
||||
|
||||
@ -1,2 +1,4 @@
|
||||
src
|
||||
tsconfig.json
|
||||
src
|
||||
dist/coverage
|
||||
*.tgz
|
||||
|
||||
@ -153,4 +153,3 @@ PokemonTCG.Card.all()
|
||||
|
||||
## TODO
|
||||
* Add more testing?
|
||||
* Update package name for easier use?
|
||||
@ -1,28 +0,0 @@
|
||||
0 info it worked if it ends with ok
|
||||
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'version', 'patch' ]
|
||||
2 info using npm@3.5.2
|
||||
3 info using node@v6.11.4
|
||||
4 info git [ 'status', '--porcelain' ]
|
||||
5 verbose stack Error: Git working directory not clean.
|
||||
5 verbose stack M README.md
|
||||
5 verbose stack M src/index.ts
|
||||
5 verbose stack at /usr/share/npm/lib/version.js:172:21
|
||||
5 verbose stack at ChildProcess.exithandler (child_process.js:189:7)
|
||||
5 verbose stack at emitTwo (events.js:106:13)
|
||||
5 verbose stack at ChildProcess.emit (events.js:191:7)
|
||||
5 verbose stack at maybeClose (internal/child_process.js:920:16)
|
||||
5 verbose stack at Socket.<anonymous> (internal/child_process.js:351:11)
|
||||
5 verbose stack at emitOne (events.js:96:13)
|
||||
5 verbose stack at Socket.emit (events.js:188:7)
|
||||
5 verbose stack at Pipe._handle.close [as _onclose] (net.js:497:12)
|
||||
6 verbose cwd /home/bradyn/Projects/pokemon-tcg-sdk-typescript
|
||||
7 error Linux 4.13.0-21-generic
|
||||
8 error argv "/usr/bin/node" "/usr/bin/npm" "version" "patch"
|
||||
9 error node v6.11.4
|
||||
10 error npm v3.5.2
|
||||
11 error Git working directory not clean.
|
||||
11 error M README.md
|
||||
11 error M src/index.ts
|
||||
12 error If you need help, you may report this error at:
|
||||
12 error <https://github.com/npm/npm/issues>
|
||||
13 verbose exit [ 1, true ]
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pokemon-tcg-sdk-typescript",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pokemon-tcg-sdk-typescript",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"description": "Typescript SDK for the PokemonTCG API (https://pokemontcg.io)",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
@ -12,16 +12,16 @@
|
||||
],
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --require ts-node/register 'src/**/*.test.ts'",
|
||||
"build" : "tsc"
|
||||
"build": "tsc"
|
||||
},
|
||||
"author": "Bradyn Glines",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PokemonTCG/pokemon-tcg-sdk-typescript"
|
||||
},
|
||||
"contributors": [
|
||||
"CptSpaceToaster",
|
||||
"Monbrey"
|
||||
"Bradyn Glines (https://github.com/glinesbdev)",
|
||||
"CptSpaceToaster (https://github.com/CptSpaceToaster)",
|
||||
"Monbrey (https://github.com/Monbrey)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
@ -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