mirror of
https://github.com/tcgdex/javascript-sdk.git
synced 2025-04-22 02:42:08 +00:00
Added raw getSet that don't process Date
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
526c65bc7c
commit
ae7f3077c0
@ -3,34 +3,37 @@ import { List } from "./General";
|
||||
import LangList from "./LangList";
|
||||
import Expansion from "./Expansion";
|
||||
|
||||
|
||||
export type SetRequest = SetSingle
|
||||
|
||||
export interface SetSingleRaw extends SetSingle {
|
||||
releaseDate: string
|
||||
}
|
||||
|
||||
export type SetSingle = {
|
||||
name: string
|
||||
code: string
|
||||
name: string
|
||||
code: string
|
||||
|
||||
expansionCode?: string
|
||||
tcgoCode?: string
|
||||
expansionCode?: string
|
||||
tcgoCode?: string
|
||||
|
||||
cardCount: {
|
||||
total: number
|
||||
official: number
|
||||
}
|
||||
cardCount: {
|
||||
total: number
|
||||
official: number
|
||||
}
|
||||
|
||||
releaseDate: Date|string
|
||||
releaseDate: Date | string
|
||||
|
||||
legal?: {
|
||||
standard: boolean
|
||||
expanded: boolean
|
||||
}
|
||||
legal?: {
|
||||
standard: boolean
|
||||
expanded: boolean
|
||||
}
|
||||
|
||||
images?: {
|
||||
symbol?: string
|
||||
logo?: string
|
||||
}
|
||||
images?: {
|
||||
symbol?: string
|
||||
logo?: string
|
||||
}
|
||||
|
||||
list: Array<CardSimple>
|
||||
list: Array<CardSimple>
|
||||
}
|
||||
|
||||
export type SetSimple = {
|
||||
|
11
tcgdex.ts
11
tcgdex.ts
@ -1,8 +1,8 @@
|
||||
import { Langs } from './interfaces/Langs'
|
||||
import { SetSingle, SetSimple, SetList } from './interfaces/Set'
|
||||
import { SetSingle, SetSimple, SetList, SetSingleRaw } from './interfaces/Set'
|
||||
import { CardSingle, CardList, CardSimple } from './interfaces/Card'
|
||||
import { ExpansionSingle, ExpansionList } from './interfaces/Expansion'
|
||||
import RequestWrapper from './Request'
|
||||
import { Langs } from './interfaces/LangList'
|
||||
|
||||
export default class TCGdex {
|
||||
public static defaultLang: Langs = "en"
|
||||
@ -44,9 +44,14 @@ export default class TCGdex {
|
||||
return resp.list
|
||||
}
|
||||
|
||||
public async getSet(set: string): Promise<SetSingle> {
|
||||
public async getSet(set: string, transformDate: false): Promise<SetSingleRaw>
|
||||
public async getSet(set: string, transformDate?: true): Promise<SetSingle>
|
||||
public async getSet(set: string, transformDate?: boolean): Promise<SetSingle | SetSingleRaw> {
|
||||
const req = this.rwgr<SetSingle>(`${this.gbu()}/sets/${set}/`)
|
||||
const resp = await req.get()
|
||||
if (!transformDate) {
|
||||
return resp as SetSingleRaw
|
||||
}
|
||||
return Object.assign(resp, {releaseDate: new Date(resp.releaseDate)}) as SetSingle
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user