@momo-cloud/gami-sdk 0.0.65 → 0.0.67

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/README.md CHANGED
@@ -135,6 +135,35 @@ console.log('Game config:', config);
135
135
 
136
136
  ---
137
137
 
138
+ #### `getExchange()`
139
+
140
+ Load exchange metadata for the current game (coin → turn). The backend uses the fixed action `exchange_coin_to_turn`; the active `gameId` comes from `init`.
141
+
142
+ ```typescript
143
+ const res = await GamiSDK.getExchange();
144
+ const { balance, exchangeRate, counter, counterLimit, fromCurrency, toCurrency } = res.result;
145
+ ```
146
+
147
+ **Returns:** `Promise<TGetExchangeResponse>` - Standard `response_info` plus `result` with rate, balances, counters, and currency pair
148
+
149
+ ---
150
+
151
+ #### `postExchange(options)`
152
+
153
+ Submit a coin-to-turn exchange for the current game.
154
+
155
+ ```typescript
156
+ const res = await GamiSDK.postExchange({ amount: 100 });
157
+ const { from, to, counter } = res.result;
158
+ ```
159
+
160
+ **Parameters:**
161
+ - `amount` (number): Coin amount to convert
162
+
163
+ **Returns:** `Promise<TPostExchangeResponse>` - Updated `from` / `to` wallet snapshots and `counter` state
164
+
165
+ ---
166
+
138
167
  #### `spin()`
139
168
 
140
169
  Perform a spinner spin for the current game. Sends `POST` to the twirler service with the active `gameId` (set via `init`).
@@ -799,11 +828,20 @@ Game Ready ✓
799
828
  The SDK is written in TypeScript and includes type definitions:
800
829
 
801
830
  ```typescript
802
- import GamiSDK, { TBalance, TLeaderboard, IUserInfo } from '@momo-cloud/gami-sdk';
831
+ import GamiSDK, {
832
+ TBalance,
833
+ TGetExchangeResponse,
834
+ TLeaderboard,
835
+ TPostExchangeResponse,
836
+ IUserInfo
837
+ } from '@momo-cloud/gami-sdk';
803
838
 
804
839
  const balance: TBalance = await GamiSDK.getBalance({
805
840
  balanceIds: ['coin']
806
841
  });
842
+
843
+ const exchangeInfo: TGetExchangeResponse = await GamiSDK.getExchange();
844
+ const posted: TPostExchangeResponse = await GamiSDK.postExchange({ amount: 100 });
807
845
  ```
808
846
 
809
847
  ### Vite Integration
@@ -57,6 +57,13 @@ declare const GamiSDK: {
57
57
  }) => Promise<any>;
58
58
  getBalanceConfig: () => Promise<any>;
59
59
  getConfig: () => Promise<any>;
60
+ getExchange: (params?: {
61
+ actionId?: string;
62
+ }) => Promise<TGetExchangeResponse>;
63
+ postExchange: (params: {
64
+ amount: number;
65
+ actionId?: string;
66
+ }) => Promise<TPostExchangeResponse>;
60
67
  spin: () => Promise<any>;
61
68
  getLeaderboard: (params: {
62
69
  boardId: string;
@@ -240,6 +247,48 @@ export declare type TDeviceInfo = {
240
247
  devicePerformance?: string;
241
248
  };
242
249
 
250
+ export declare type TGetExchangeResponse = {
251
+ response_info: {
252
+ error_message: string;
253
+ error_code: number;
254
+ event_tracking: string;
255
+ };
256
+ result: {
257
+ balance: number;
258
+ exchangeRate: number;
259
+ counter: number;
260
+ counterLimit: number;
261
+ fromCurrency: string;
262
+ toCurrency: string;
263
+ };
264
+ };
265
+
266
+ export declare type TPostExchangeResponse = {
267
+ response_info: {
268
+ error_message: string;
269
+ error_code: number;
270
+ event_tracking: string;
271
+ };
272
+ result: {
273
+ from: {
274
+ walletType: string;
275
+ currency: string;
276
+ before: number;
277
+ after: number;
278
+ };
279
+ to: {
280
+ walletType: string;
281
+ currency: string;
282
+ before: number;
283
+ after: number;
284
+ };
285
+ counter: {
286
+ value: number;
287
+ limit: number;
288
+ };
289
+ };
290
+ };
291
+
243
292
  export declare const Utils: {
244
293
  num10to11: (number: string) => string;
245
294
  num11to10: (number: string) => string;