@gamecore-api/sdk 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +23 -1
- package/dist/index.js +12 -0
- package/dist/types.d.ts +19 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TelegramInitResponse, User, SiteConfig, ExchangeRates, LegalDocument, Game, GameDetail, Product, SearchResult, Category, CartItem, CheckoutRequest, CheckoutResponse, Order, UserBalance, LevelStatus, Transaction, Notification, Favorite, Review, ReviewStats, CouponResult, ReferralStats, ReferralLink, ReferralCommission, TopupMethod, TopupResponse, TopupStatus, GiftCard, Announcement, AnnouncementBar, SiteStats, ProductFilters, PaginatedResponse } from "./types";
|
|
1
|
+
import type { TelegramInitResponse, User, SiteConfig, ExchangeRates, LegalDocument, Game, GameDetail, Product, SearchResult, Category, CartItem, CheckoutRequest, CheckoutResponse, Order, UserBalance, LevelStatus, Transaction, Notification, Favorite, Review, ReviewStats, CouponResult, ReferralStats, ReferralLink, ReferralCommission, TopupMethod, TopupResponse, TopupStatus, GiftCard, Announcement, AnnouncementBar, CatalogSection, SiteStats, ProductFilters, PaginatedResponse } from "./types";
|
|
2
2
|
export interface GameCoreOptions {
|
|
3
3
|
/** Site API key (gc_live_xxx or gc_test_xxx) */
|
|
4
4
|
apiKey: string;
|
|
@@ -22,6 +22,24 @@ export declare class GameCoreClient {
|
|
|
22
22
|
getLegal: (type: string, locale?: string) => Promise<LegalDocument>;
|
|
23
23
|
/** Get site statistics for trust signals (cached 5 min on server) */
|
|
24
24
|
getStats: () => Promise<SiteStats>;
|
|
25
|
+
/** Get cookie consent config */
|
|
26
|
+
getCookieConsent: () => Promise<{
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
text: string;
|
|
29
|
+
policyUrl: string;
|
|
30
|
+
}>;
|
|
31
|
+
/** Get per-site catalog sections (category tabs config) */
|
|
32
|
+
getCatalogSections: () => Promise<CatalogSection[]>;
|
|
33
|
+
/** Get active hero banners for carousel */
|
|
34
|
+
getBanners: () => Promise<{
|
|
35
|
+
id: number;
|
|
36
|
+
title: string | null;
|
|
37
|
+
description: string | null;
|
|
38
|
+
imageUrl: string | null;
|
|
39
|
+
color: string | null;
|
|
40
|
+
scope: string;
|
|
41
|
+
priority: number;
|
|
42
|
+
}[]>;
|
|
25
43
|
/** Get announcement bar settings (text, link, enabled) */
|
|
26
44
|
getAnnouncementBar: () => Promise<AnnouncementBar>;
|
|
27
45
|
};
|
|
@@ -60,11 +78,14 @@ export declare class GameCoreClient {
|
|
|
60
78
|
deliveryType?: string;
|
|
61
79
|
include?: string;
|
|
62
80
|
inStockOnly?: boolean;
|
|
81
|
+
sort?: "popular" | "name" | "new" | "soldCount";
|
|
63
82
|
}) => Promise<Game[]>;
|
|
64
83
|
/** Get homepage ranked games */
|
|
65
84
|
getHomepageGames: () => Promise<Game[]>;
|
|
66
85
|
/** Get single game with categories */
|
|
67
86
|
getGame: (slug: string, locale?: string) => Promise<GameDetail>;
|
|
87
|
+
/** Get recommended games (same type, random) */
|
|
88
|
+
getRecommendations: (gameSlug: string, limit?: number) => Promise<Game[]>;
|
|
68
89
|
/** Get categories for a game with product counts and delivery metadata */
|
|
69
90
|
getCategories: (gameSlug: string) => Promise<Category[]>;
|
|
70
91
|
/** Get products for a game with optional filters */
|
|
@@ -236,6 +257,7 @@ export declare class GameCoreClient {
|
|
|
236
257
|
/** Get public reviews (paginated) */
|
|
237
258
|
listPublic: (params?: {
|
|
238
259
|
gameSlug?: string;
|
|
260
|
+
productId?: number;
|
|
239
261
|
limit?: number;
|
|
240
262
|
offset?: number;
|
|
241
263
|
}) => Promise<PaginatedResponse<Review>>;
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,9 @@ class GameCoreClient {
|
|
|
77
77
|
getRates: () => this.request("GET", "/rates"),
|
|
78
78
|
getLegal: (type, locale) => this.request("GET", `/legal/${type}${locale ? `?locale=${locale}` : ""}`),
|
|
79
79
|
getStats: () => this.request("GET", "/site/stats"),
|
|
80
|
+
getCookieConsent: () => this.request("GET", "/site/cookie-consent"),
|
|
81
|
+
getCatalogSections: () => this.request("GET", "/site/catalog-sections"),
|
|
82
|
+
getBanners: () => this.request("GET", "/site/banners"),
|
|
80
83
|
getAnnouncementBar: () => this.request("GET", "/site/announcement-bar")
|
|
81
84
|
};
|
|
82
85
|
auth = {
|
|
@@ -118,6 +121,8 @@ class GameCoreClient {
|
|
|
118
121
|
qs.set("include", params.include);
|
|
119
122
|
if (params?.inStockOnly)
|
|
120
123
|
qs.set("inStockOnly", "true");
|
|
124
|
+
if (params?.sort)
|
|
125
|
+
qs.set("sort", params.sort);
|
|
121
126
|
const q = qs.toString();
|
|
122
127
|
return this.request("GET", `/catalog/games${q ? `?${q}` : ""}`);
|
|
123
128
|
},
|
|
@@ -126,6 +131,7 @@ class GameCoreClient {
|
|
|
126
131
|
const qs = locale ? `?locale=${locale}` : "";
|
|
127
132
|
return this.request("GET", `/catalog/games/${slug}${qs}`);
|
|
128
133
|
},
|
|
134
|
+
getRecommendations: (gameSlug, limit = 8) => this.request("GET", `/catalog/games/${gameSlug}/recommendations?limit=${limit}`),
|
|
129
135
|
getCategories: (gameSlug) => this.request("GET", `/catalog/games/${gameSlug}/categories`),
|
|
130
136
|
getProducts: (gameSlug, filters) => {
|
|
131
137
|
const qs = new URLSearchParams;
|
|
@@ -137,6 +143,10 @@ class GameCoreClient {
|
|
|
137
143
|
qs.set("platform", filters.platform);
|
|
138
144
|
if (filters?.categoryId)
|
|
139
145
|
qs.set("categoryId", String(filters.categoryId));
|
|
146
|
+
if (filters?.minPrice != null)
|
|
147
|
+
qs.set("minPrice", String(filters.minPrice));
|
|
148
|
+
if (filters?.maxPrice != null)
|
|
149
|
+
qs.set("maxPrice", String(filters.maxPrice));
|
|
140
150
|
const q = qs.toString();
|
|
141
151
|
return this.request("GET", `/catalog/games/${gameSlug}/products${q ? `?${q}` : ""}`);
|
|
142
152
|
},
|
|
@@ -214,6 +224,8 @@ class GameCoreClient {
|
|
|
214
224
|
const qs = new URLSearchParams;
|
|
215
225
|
if (params?.gameSlug)
|
|
216
226
|
qs.set("gameSlug", params.gameSlug);
|
|
227
|
+
if (params?.productId)
|
|
228
|
+
qs.set("productId", String(params.productId));
|
|
217
229
|
if (params?.limit)
|
|
218
230
|
qs.set("limit", String(params.limit));
|
|
219
231
|
if (params?.offset)
|
package/dist/types.d.ts
CHANGED
|
@@ -37,6 +37,14 @@ export interface SiteConfig {
|
|
|
37
37
|
enabled: boolean;
|
|
38
38
|
message: string | null;
|
|
39
39
|
};
|
|
40
|
+
analytics?: {
|
|
41
|
+
yandex: {
|
|
42
|
+
counterId: string;
|
|
43
|
+
} | null;
|
|
44
|
+
google: {
|
|
45
|
+
measurementId: string;
|
|
46
|
+
} | null;
|
|
47
|
+
};
|
|
40
48
|
}
|
|
41
49
|
export interface ExchangeRates {
|
|
42
50
|
usdToRub: number;
|
|
@@ -161,6 +169,8 @@ export interface ProductFilters {
|
|
|
161
169
|
region?: string;
|
|
162
170
|
platform?: string;
|
|
163
171
|
categoryId?: number;
|
|
172
|
+
minPrice?: number;
|
|
173
|
+
maxPrice?: number;
|
|
164
174
|
}
|
|
165
175
|
export interface SearchResult {
|
|
166
176
|
games: Game[];
|
|
@@ -387,6 +397,15 @@ export interface Announcement {
|
|
|
387
397
|
imageUrl?: string | null;
|
|
388
398
|
createdAt: string;
|
|
389
399
|
}
|
|
400
|
+
export interface CatalogSection {
|
|
401
|
+
id: number;
|
|
402
|
+
slug: string;
|
|
403
|
+
label: string;
|
|
404
|
+
icon: string | null;
|
|
405
|
+
filterType: string;
|
|
406
|
+
filterValue: string;
|
|
407
|
+
sortOrder: number;
|
|
408
|
+
}
|
|
390
409
|
export interface SiteStats {
|
|
391
410
|
totalCustomers: number;
|
|
392
411
|
totalOrders: number;
|