mirror of
https://github.com/tcgdex/javascript-sdk.git
synced 2025-04-22 10:42:10 +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 LangList from "./LangList";
|
||||||
import Expansion from "./Expansion";
|
import Expansion from "./Expansion";
|
||||||
|
|
||||||
|
|
||||||
export type SetRequest = SetSingle
|
export type SetRequest = SetSingle
|
||||||
|
|
||||||
|
export interface SetSingleRaw extends SetSingle {
|
||||||
|
releaseDate: string
|
||||||
|
}
|
||||||
|
|
||||||
export type SetSingle = {
|
export type SetSingle = {
|
||||||
name: string
|
name: string
|
||||||
code: string
|
code: string
|
||||||
|
|
||||||
expansionCode?: string
|
expansionCode?: string
|
||||||
tcgoCode?: string
|
tcgoCode?: string
|
||||||
|
|
||||||
cardCount: {
|
cardCount: {
|
||||||
total: number
|
total: number
|
||||||
official: number
|
official: number
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseDate: Date|string
|
releaseDate: Date | string
|
||||||
|
|
||||||
legal?: {
|
legal?: {
|
||||||
standard: boolean
|
standard: boolean
|
||||||
expanded: boolean
|
expanded: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
images?: {
|
images?: {
|
||||||
symbol?: string
|
symbol?: string
|
||||||
logo?: string
|
logo?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
list: Array<CardSimple>
|
list: Array<CardSimple>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SetSimple = {
|
export type SetSimple = {
|
||||||
|
11
tcgdex.ts
11
tcgdex.ts
@ -1,8 +1,8 @@
|
|||||||
import { Langs } from './interfaces/Langs'
|
import { SetSingle, SetSimple, SetList, SetSingleRaw } from './interfaces/Set'
|
||||||
import { SetSingle, SetSimple, SetList } from './interfaces/Set'
|
|
||||||
import { CardSingle, CardList, CardSimple } from './interfaces/Card'
|
import { CardSingle, CardList, CardSimple } from './interfaces/Card'
|
||||||
import { ExpansionSingle, ExpansionList } from './interfaces/Expansion'
|
import { ExpansionSingle, ExpansionList } from './interfaces/Expansion'
|
||||||
import RequestWrapper from './Request'
|
import RequestWrapper from './Request'
|
||||||
|
import { Langs } from './interfaces/LangList'
|
||||||
|
|
||||||
export default class TCGdex {
|
export default class TCGdex {
|
||||||
public static defaultLang: Langs = "en"
|
public static defaultLang: Langs = "en"
|
||||||
@ -44,9 +44,14 @@ export default class TCGdex {
|
|||||||
return resp.list
|
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 req = this.rwgr<SetSingle>(`${this.gbu()}/sets/${set}/`)
|
||||||
const resp = await req.get()
|
const resp = await req.get()
|
||||||
|
if (!transformDate) {
|
||||||
|
return resp as SetSingleRaw
|
||||||
|
}
|
||||||
return Object.assign(resp, {releaseDate: new Date(resp.releaseDate)}) as SetSingle
|
return Object.assign(resp, {releaseDate: new Date(resp.releaseDate)}) as SetSingle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user