@gamecore-api/sdk 0.7.0 → 0.8.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 +26 -8
- package/dist/index.js +14 -3
- package/dist/types.d.ts +7 -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, SiteUIConfig, CatalogSection, 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, SiteUIConfig, PaymentMethod, 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;
|
|
@@ -73,6 +73,16 @@ export declare class GameCoreClient {
|
|
|
73
73
|
linkVk: (accessToken: string) => Promise<void>;
|
|
74
74
|
/** Unlink auth provider */
|
|
75
75
|
unlinkProvider: (provider: string) => Promise<void>;
|
|
76
|
+
/** Preview VK account merge (before confirming) */
|
|
77
|
+
mergePreview: (accessToken: string) => Promise<{
|
|
78
|
+
preview: Record<string, unknown>;
|
|
79
|
+
}>;
|
|
80
|
+
/** Confirm VK account merge */
|
|
81
|
+
mergeConfirm: (accessToken: string) => Promise<{
|
|
82
|
+
success: boolean;
|
|
83
|
+
provider: string;
|
|
84
|
+
vkId: string;
|
|
85
|
+
}>;
|
|
76
86
|
};
|
|
77
87
|
catalog: {
|
|
78
88
|
/** Get all games. Use inStockOnly:true for only games with products. include:"meta" for categories/deliveryTypes. */
|
|
@@ -107,6 +117,12 @@ export declare class GameCoreClient {
|
|
|
107
117
|
}>;
|
|
108
118
|
/** Get single product by ID */
|
|
109
119
|
getProduct: (productId: number) => Promise<Product>;
|
|
120
|
+
/** Get user's recently viewed games (auth required) */
|
|
121
|
+
getRecentGames: () => Promise<Game[]>;
|
|
122
|
+
/** Get user's search history — returns list of recent query strings (auth required) */
|
|
123
|
+
getSearchHistory: () => Promise<string[]>;
|
|
124
|
+
/** Save search query to history (auth required) */
|
|
125
|
+
saveSearchHistory: (query: string) => Promise<void>;
|
|
110
126
|
/** Get bundle discount rules */
|
|
111
127
|
getBundleRules: () => Promise<{
|
|
112
128
|
id: number;
|
|
@@ -159,13 +175,7 @@ export declare class GameCoreClient {
|
|
|
159
175
|
success: boolean;
|
|
160
176
|
}>;
|
|
161
177
|
/** Get available payment methods for checkout */
|
|
162
|
-
getPaymentMethods: () => Promise<
|
|
163
|
-
type: string;
|
|
164
|
-
label: string;
|
|
165
|
-
description?: string;
|
|
166
|
-
feePercent?: number;
|
|
167
|
-
gatewayType?: string;
|
|
168
|
-
}[]>;
|
|
178
|
+
getPaymentMethods: () => Promise<PaymentMethod[]>;
|
|
169
179
|
};
|
|
170
180
|
orders: {
|
|
171
181
|
/** List all orders for authenticated user */
|
|
@@ -208,6 +218,14 @@ export declare class GameCoreClient {
|
|
|
208
218
|
deleteAccount: () => Promise<void>;
|
|
209
219
|
/** Export user data (GDPR) */
|
|
210
220
|
exportData: () => Promise<Record<string, unknown>>;
|
|
221
|
+
/** Subscribe to broadcast notifications */
|
|
222
|
+
subscribeBroadcast: () => Promise<void>;
|
|
223
|
+
/** Unsubscribe from broadcast notifications */
|
|
224
|
+
unsubscribeBroadcast: () => Promise<void>;
|
|
225
|
+
/** Get broadcast subscription status */
|
|
226
|
+
getBroadcastStatus: () => Promise<{
|
|
227
|
+
subscribed: boolean;
|
|
228
|
+
}>;
|
|
211
229
|
};
|
|
212
230
|
favorites: {
|
|
213
231
|
/** List user's favorite products */
|
package/dist/index.js
CHANGED
|
@@ -108,7 +108,9 @@ class GameCoreClient {
|
|
|
108
108
|
logout: () => this.request("POST", "/auth/logout"),
|
|
109
109
|
getIdentities: () => this.request("GET", "/auth/identities", undefined, { rawResponse: true }),
|
|
110
110
|
linkVk: (accessToken) => this.request("POST", "/auth/link/vk", { accessToken }),
|
|
111
|
-
unlinkProvider: (provider) => this.request("POST", `/auth/unlink/${provider}`)
|
|
111
|
+
unlinkProvider: (provider) => this.request("POST", `/auth/unlink/${provider}`),
|
|
112
|
+
mergePreview: (accessToken) => this.request("POST", "/auth/merge/preview", { accessToken }),
|
|
113
|
+
mergeConfirm: (accessToken) => this.request("POST", "/auth/merge/confirm", { accessToken })
|
|
112
114
|
};
|
|
113
115
|
catalog = {
|
|
114
116
|
getGames: (params) => {
|
|
@@ -156,6 +158,9 @@ class GameCoreClient {
|
|
|
156
158
|
search: (query, limit = 20) => this.request("GET", `/catalog/search?q=${encodeURIComponent(query)}&limit=${limit}`),
|
|
157
159
|
searchSuggestions: (query, limit = 5) => this.request("GET", `/catalog/search/suggestions?q=${encodeURIComponent(query)}&limit=${limit}`),
|
|
158
160
|
getProduct: (productId) => this.request("GET", `/catalog/products/${productId}`),
|
|
161
|
+
getRecentGames: () => this.request("GET", "/catalog/recent-games"),
|
|
162
|
+
getSearchHistory: () => this.request("GET", "/catalog/search-history"),
|
|
163
|
+
saveSearchHistory: (query) => this.request("POST", "/catalog/search-history", { query }),
|
|
159
164
|
getBundleRules: () => this.request("GET", "/catalog/bundle-rules"),
|
|
160
165
|
getPromos: () => this.request("GET", "/catalog/promos"),
|
|
161
166
|
getGamesFull: () => this.request("GET", "/catalog/games/full"),
|
|
@@ -173,7 +178,10 @@ class GameCoreClient {
|
|
|
173
178
|
idempotencyKey: idempotencyKey || generateIdempotencyKey()
|
|
174
179
|
}),
|
|
175
180
|
completeWithBalance: (paymentCode) => this.request("POST", `/checkout/${paymentCode}/complete`),
|
|
176
|
-
getPaymentMethods: () =>
|
|
181
|
+
getPaymentMethods: async () => {
|
|
182
|
+
const res = await this.request("GET", "/checkout/payment-methods", undefined, { rawResponse: true });
|
|
183
|
+
return res.methods || [];
|
|
184
|
+
}
|
|
177
185
|
};
|
|
178
186
|
orders = {
|
|
179
187
|
list: () => this.request("GET", "/orders"),
|
|
@@ -199,7 +207,10 @@ class GameCoreClient {
|
|
|
199
207
|
markRead: (id) => this.request("POST", `/profile/notifications/${id}/read`),
|
|
200
208
|
markAllRead: () => this.request("POST", "/profile/notifications/read-all"),
|
|
201
209
|
deleteAccount: () => this.request("POST", "/profile/delete-account"),
|
|
202
|
-
exportData: () => this.request("GET", "/profile/export")
|
|
210
|
+
exportData: () => this.request("GET", "/profile/export"),
|
|
211
|
+
subscribeBroadcast: () => this.request("POST", "/profile/broadcast/subscribe"),
|
|
212
|
+
unsubscribeBroadcast: () => this.request("POST", "/profile/broadcast/unsubscribe"),
|
|
213
|
+
getBroadcastStatus: () => this.request("GET", "/profile/broadcast/status")
|
|
203
214
|
};
|
|
204
215
|
favorites = {
|
|
205
216
|
list: () => this.request("GET", "/favorites"),
|
package/dist/types.d.ts
CHANGED
|
@@ -434,6 +434,13 @@ export interface SiteUIConfig {
|
|
|
434
434
|
enabled: boolean;
|
|
435
435
|
}>;
|
|
436
436
|
}
|
|
437
|
+
export interface PaymentMethod {
|
|
438
|
+
type: string;
|
|
439
|
+
label: string;
|
|
440
|
+
description?: string;
|
|
441
|
+
feePercent?: number;
|
|
442
|
+
gatewayType?: string;
|
|
443
|
+
}
|
|
437
444
|
export interface CatalogSection {
|
|
438
445
|
id: number;
|
|
439
446
|
slug: string;
|