Compare commits

..

5 Commits

Author SHA1 Message Date
624337467b v1.3.0 2020-03-18 09:54:05 +01:00
eb96cb971c v1.2.1 2020-03-14 20:08:22 +01:00
9902888304 Fix datas not in interface
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
2020-03-14 20:08:00 +01:00
2f1a293e3d v1.2.0 2020-03-14 20:00:43 +01:00
04d13bd450 Updated DB to add items
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
2020-03-14 19:56:59 +01:00
3 changed files with 22 additions and 7 deletions

View File

@ -33,6 +33,14 @@ export interface CardSingle {
name: string
code: string
}
/**
* Some Pokémons have item like a berry
*/
item?: {
name: string
effect: string
}
cardTypes?: {
/**
* normal card without anything special
@ -120,6 +128,11 @@ type Card = {
// If card is trainer or energy effect is here
effect?: LangList<string>
item?: {
name: LangList<string>
effect: LangList<string>
}
weaknesses?: Array<{
type: Type
value?: string

View File

@ -1,8 +1,8 @@
{
"name": "@tcgdex/sdk",
"version": "1.2.0-beta.1",
"version": "1.3.0",
"main": "./tcgdex.js",
"types": "./types/tcgdex.d.ts",
"types": "./tcgdex.d.ts",
"repository": "https://git.delta-wings.net/tcgdex/javascript-sdk.git",
"license": "MIT",
"devDependencies": {

View File

@ -1,7 +1,7 @@
import fetch from 'isomorphic-unfetch'
import { Langs } from './interfaces/Langs'
import { SetSingle, SetRequest, SetSimple } from './interfaces/Set'
import { CardSingle } from './interfaces/Card'
import { SetSingle, SetRequest, SetSimple, SetList } from './interfaces/Set'
import { CardSingle, CardList, CardSimple } from './interfaces/Card'
import { ExpansionSingle, ExpansionList } from './interfaces/Expansion'
export default class TCGdex {
@ -36,7 +36,7 @@ export default class TCGdex {
}
}
public async getCards(set?: string) {
public async getCards(set?: string): Promise<Array<CardSimple>> {
if (set) {
try {
const setSingle = await this.getSet(set)
@ -52,7 +52,8 @@ export default class TCGdex {
throw new Error("Could not fetch cards")
}
try {
return resp.json()
const t: CardList = await resp.json()
return t.list
} catch (e) {
throw e
}
@ -120,7 +121,8 @@ export default class TCGdex {
throw new Error("Could not fetch sets")
}
try {
return resp.json()
const sets: SetList = await resp.json()
return sets.list
} catch (e) {
throw e
}