// ApiVersion is optional and defaults to v4
const sdk = new YShopSdk ( shopId : number , apiVersion ?: string) ;
Get info about current shop
await sdk . shopModule . find ( ) ;
// returns
ShopEntity {
id: number
name: string
slug: string
imageUrl: string
isActive: boolean
domain: string
domainIsActive: boolean
isPremium: boolean
created_at: string
updated_at: string
settings: Settings {
id : number
}
}
await sdk . shopModule . findServers ( ) ;
// returns
ServerEntity [ ] {
id : number
name : string
imageUrl : string
isOnline : boolean
online : number
maxOnline : number
game : string
created_at : string
updated_at : string
}
Get last buyers from server
await sdk . shopModule . getLastBuyeres ( serverId : number) ;
// returns
LastBuyerEntity {
nickname: string
count: number
}
await sdk . shopModule . useVoucher ( code : string , nickname : string) ;
await sdk . shopModule . getDiscountCode ( code : string , serverId ?: number, productId ?: number) ;
// returns
DiscountCodeEntity {
id: number
discount: number
code: string
product: Product {
id : number
}
server: Server {
id : number
}
}
await sdk . shopModule . getWidgets ( ) ;
// returns
WidgetEntity [ ] {
id : number
type : string
config : any
created_at : string
updated_at : string
name : string
}
Get every product in shop
await sdk . productsModule . find ( ) ;
// returns
ProductEntity [ ] {
id : number
name : string
imageUrl : string
description : string
commands : string
purchases : number
displayPrice : string
requireOnline : boolean
order : number
created_at : string
updated_at : string
slider : Slider {
id : number
enable : boolean
min : number
max : number
name : string
}
server : Server {
id : number
name : string
}
}
Get only one product in shop
await sdk . productsModule . findById ( productId : number) ;
// returns
ProductEntity {
id: number
name: string
imageUrl: string
description: string
commands: string
purchases: number
displayPrice: string
requireOnline: boolean
order: number
created_at: string
updated_at: string
slider: Slider {
id: number
enable: boolean
min: number
max: number
name: string
}
server: Server {
id: number
name: string
}
}
Transaction {
productId: number
nickname: string
email: string
method: string
count: number
redirectUrl?: string
discountCodeId?: number
}
await sdk . paymentsModule . init ( transaction : Transaction ) ;
// returns
PaymentEntity {
url: string
provider_id: string
transaction_id: string
}
await sdk . paymentsModule . find ( transactionId : string) ;
// returns
TransactionEntity {
id: string
status: string
nickname: string
email: string
count: number
control: string
gateway: string
price: number
finalPrice: number
}