mirror of
https://github.com/tcgdex/javascript-sdk.git
synced 2025-07-14 02:45:11 +00:00
Compare commits
5 Commits
1.2.0-beta
...
1.3.0
Author | SHA1 | Date | |
---|---|---|---|
624337467b | |||
eb96cb971c | |||
9902888304 | |||
2f1a293e3d | |||
04d13bd450 |
@ -33,6 +33,14 @@ export interface CardSingle {
|
|||||||
name: string
|
name: string
|
||||||
code: string
|
code: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some Pokémons have item like a berry
|
||||||
|
*/
|
||||||
|
item?: {
|
||||||
|
name: string
|
||||||
|
effect: string
|
||||||
|
}
|
||||||
cardTypes?: {
|
cardTypes?: {
|
||||||
/**
|
/**
|
||||||
* normal card without anything special
|
* normal card without anything special
|
||||||
@ -120,6 +128,11 @@ type Card = {
|
|||||||
// If card is trainer or energy effect is here
|
// If card is trainer or energy effect is here
|
||||||
effect?: LangList<string>
|
effect?: LangList<string>
|
||||||
|
|
||||||
|
item?: {
|
||||||
|
name: LangList<string>
|
||||||
|
effect: LangList<string>
|
||||||
|
}
|
||||||
|
|
||||||
weaknesses?: Array<{
|
weaknesses?: Array<{
|
||||||
type: Type
|
type: Type
|
||||||
value?: string
|
value?: string
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@tcgdex/sdk",
|
"name": "@tcgdex/sdk",
|
||||||
"version": "1.2.0-beta.1",
|
"version": "1.3.0",
|
||||||
"main": "./tcgdex.js",
|
"main": "./tcgdex.js",
|
||||||
"types": "./types/tcgdex.d.ts",
|
"types": "./tcgdex.d.ts",
|
||||||
"repository": "https://git.delta-wings.net/tcgdex/javascript-sdk.git",
|
"repository": "https://git.delta-wings.net/tcgdex/javascript-sdk.git",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
12
tcgdex.ts
12
tcgdex.ts
@ -1,7 +1,7 @@
|
|||||||
import fetch from 'isomorphic-unfetch'
|
import fetch from 'isomorphic-unfetch'
|
||||||
import { Langs } from './interfaces/Langs'
|
import { Langs } from './interfaces/Langs'
|
||||||
import { SetSingle, SetRequest, SetSimple } from './interfaces/Set'
|
import { SetSingle, SetRequest, SetSimple, SetList } from './interfaces/Set'
|
||||||
import { CardSingle } from './interfaces/Card'
|
import { CardSingle, CardList, CardSimple } from './interfaces/Card'
|
||||||
import { ExpansionSingle, ExpansionList } from './interfaces/Expansion'
|
import { ExpansionSingle, ExpansionList } from './interfaces/Expansion'
|
||||||
|
|
||||||
export default class TCGdex {
|
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) {
|
if (set) {
|
||||||
try {
|
try {
|
||||||
const setSingle = await this.getSet(set)
|
const setSingle = await this.getSet(set)
|
||||||
@ -52,7 +52,8 @@ export default class TCGdex {
|
|||||||
throw new Error("Could not fetch cards")
|
throw new Error("Could not fetch cards")
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return resp.json()
|
const t: CardList = await resp.json()
|
||||||
|
return t.list
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
@ -120,7 +121,8 @@ export default class TCGdex {
|
|||||||
throw new Error("Could not fetch sets")
|
throw new Error("Could not fetch sets")
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return resp.json()
|
const sets: SetList = await resp.json()
|
||||||
|
return sets.list
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user