@gt6/sdk 1.0.44 → 1.0.45

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.
@@ -3287,6 +3287,110 @@ class TransactionsAPI {
3287
3287
  };
3288
3288
  }
3289
3289
  }
3290
+ /**
3291
+ * 获取用户平台信息
3292
+ * @param platformId 平台ID
3293
+ * @returns 用户平台信息响应
3294
+ */
3295
+ async getUserInfo(platformId) {
3296
+ try {
3297
+ // 构建API URL
3298
+ const apiUrl = `/platforms/${platformId}.json`;
3299
+ const response = await this.client.request(apiUrl, {
3300
+ method: 'GET',
3301
+ headers: {
3302
+ 'Content-Type': 'application/json'
3303
+ }
3304
+ });
3305
+ // 检查响应格式
3306
+ if (response && typeof response === 'object') {
3307
+ // 验证响应数据结构
3308
+ const userData = response;
3309
+ // 检查必要字段是否存在
3310
+ if (userData.id && userData.platformName) {
3311
+ return {
3312
+ success: true,
3313
+ message: '获取用户信息成功',
3314
+ data: userData
3315
+ };
3316
+ }
3317
+ else {
3318
+ return {
3319
+ success: false,
3320
+ message: '响应数据格式不正确'
3321
+ };
3322
+ }
3323
+ }
3324
+ return {
3325
+ success: false,
3326
+ message: '响应格式错误'
3327
+ };
3328
+ }
3329
+ catch (error) {
3330
+ // 如果是HTTP错误,尝试解析响应体
3331
+ if (error.statusCode && error.message) {
3332
+ // 对于401错误,返回认证失败信息
3333
+ if (error.statusCode === 401) {
3334
+ return {
3335
+ success: false,
3336
+ message: '认证失败,请重新登录'
3337
+ };
3338
+ }
3339
+ // 对于404错误,平台不存在
3340
+ if (error.statusCode === 404) {
3341
+ return {
3342
+ success: false,
3343
+ message: '平台不存在或已被删除'
3344
+ };
3345
+ }
3346
+ // 对于其他HTTP错误,返回状态码信息
3347
+ return {
3348
+ success: false,
3349
+ message: error.message || `HTTP ${error.statusCode} 错误`
3350
+ };
3351
+ }
3352
+ // 对于网络错误或其他错误
3353
+ return {
3354
+ success: false,
3355
+ message: error instanceof Error ? error.message : '获取用户信息失败'
3356
+ };
3357
+ }
3358
+ }
3359
+ /**
3360
+ * 1. 根据字段名查询字段值
3361
+ * @param platformInfo 平台信息数组
3362
+ * @param fieldName 字段名称
3363
+ * @returns 字段值或null
3364
+ */
3365
+ getFieldByName(platformInfo, fieldName) {
3366
+ const field = platformInfo.find(info => info.fieldName === fieldName);
3367
+ return field ? field.fieldValue : null;
3368
+ }
3369
+ /**
3370
+ * 2. 根据别名查询字段值
3371
+ * @param platformInfo 平台信息数组
3372
+ * @param aliases 别名
3373
+ * @returns 字段值数组
3374
+ */
3375
+ getFieldsByAliases(platformInfo, aliases) {
3376
+ return platformInfo.filter(info => info.aliases === aliases);
3377
+ }
3378
+ /**
3379
+ * 3. 获取管理员信息
3380
+ * @param userInfo 用户平台信息
3381
+ * @returns 管理员信息数组
3382
+ */
3383
+ getAdminsInfo(userInfo) {
3384
+ return userInfo.admins || [];
3385
+ }
3386
+ /**
3387
+ * 4. 获取资金信息
3388
+ * @param userInfo 用户平台信息
3389
+ * @returns 资金信息对象
3390
+ */
3391
+ getFundInfo(userInfo) {
3392
+ return userInfo.fund || null;
3393
+ }
3290
3394
  }
3291
3395
 
3292
3396
  /**