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