@gamecore-api/sdk 0.24.0 → 0.25.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 CHANGED
@@ -1,4 +1,6 @@
1
1
  import type { Announcement, AnnouncementBar, CartItem, CashbackPreview, CatalogSection, Category, CategoryInfo, CheckoutRequest, CheckoutResponse, CheckoutStatus, CmsArticleListResponse, CmsArticleLocale, CmsArticleResponse, CmsArticleType, CompleteWithBalanceResult, Conversation, ConversationDetail, CouponResult, DailyBonusClaimResult, DailyBonusStatus, DeliveryHelpResponse, ExchangeRates, FaqListResponse, Favorite, Game, GameDetail, GameRequestList, GiftCard, LegalDocument, LevelStatus, Notification, Order, PagedGamesResponse, PlatformInfo, PaginatedResponse, PaymentInfo, PaymentMethod, Product, ProductFilters, ProfileSummary, PublicCoupon, Quest, QuestCompleteResult, ReferralCommission, ReferralLink, ReferralPerformance, ReferralStats, ReferralTransferResult, Review, ReviewCreateResult, ReviewPolicy, ReviewProof, ReviewStats, ScreenshotsResponse, SearchResult, SiteConfig, SiteStats, SiteUIConfig, SystemRequirementsResponse, TelegramAuthResponse, TelegramBotLoginOptions, TelegramInitResponse, TelegramWidgetRenderOptions, TelegramWidgetUser, TopupMethod, TopupResponse, TopupStatus, Transaction, User, UserBalance, WebPushSubscriptionInput } from "./types";
2
+ /** Supported storefront locales — extend as new languages land. */
3
+ export type SdkLocale = "ru" | "en";
2
4
  export interface GameCoreOptions {
3
5
  /** Site API key (gc_live_xxx or gc_test_xxx) */
4
6
  apiKey: string;
@@ -6,12 +8,29 @@ export interface GameCoreOptions {
6
8
  baseUrl: string;
7
9
  /** Called on 401 — use to redirect to login */
8
10
  onAuthError?: () => void;
11
+ /**
12
+ * Default locale for catalog/CMS responses. When set, every request
13
+ * sends an `Accept-Language` header so the API returns localized
14
+ * name/description fields without each call passing `locale=` itself.
15
+ * Per-call `locale` arguments still take precedence over the default.
16
+ * Omit to keep the legacy behaviour (server falls back to "ru").
17
+ */
18
+ locale?: SdkLocale;
9
19
  }
10
20
  export declare class GameCoreClient {
11
21
  private apiKey;
12
22
  private baseUrl;
13
23
  private onAuthError?;
24
+ private defaultLocale?;
14
25
  constructor(options: GameCoreOptions);
26
+ /**
27
+ * Switch the client's default locale at runtime — useful for a
28
+ * storefront language switcher that should not have to re-instantiate
29
+ * the client.
30
+ */
31
+ setLocale(locale: SdkLocale | undefined): void;
32
+ /** Current default locale (undefined when none set). */
33
+ getLocale(): SdkLocale | undefined;
15
34
  private request;
16
35
  site: {
17
36
  /** Get site configuration (modules, auth methods, payments, currency) */
package/dist/index.js CHANGED
@@ -36,16 +36,27 @@ class GameCoreClient {
36
36
  apiKey;
37
37
  baseUrl;
38
38
  onAuthError;
39
+ defaultLocale;
39
40
  constructor(options) {
40
41
  this.apiKey = options.apiKey;
41
42
  this.baseUrl = options.baseUrl.replace(/\/$/, "");
42
43
  this.onAuthError = options.onAuthError;
44
+ this.defaultLocale = options.locale;
45
+ }
46
+ setLocale(locale) {
47
+ this.defaultLocale = locale;
48
+ }
49
+ getLocale() {
50
+ return this.defaultLocale;
43
51
  }
44
52
  async request(method, path, body, options) {
45
53
  const headers = {
46
54
  "X-Api-Key": this.apiKey,
47
55
  "Content-Type": "application/json"
48
56
  };
57
+ if (this.defaultLocale) {
58
+ headers["Accept-Language"] = this.defaultLocale;
59
+ }
49
60
  if (options?.idempotencyKey) {
50
61
  headers["X-Idempotency-Key"] = options.idempotencyKey;
51
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamecore-api/sdk",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "TypeScript SDK for GameCore API — browser-safe, zero dependencies",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",