import 'package:flutter/foundation.dart';
import 'package:yumi/shared/business_logic/models/req/sc_user_profile_cmd.dart';
import 'package:yumi/shared/business_logic/models/res/sc_gold_record_res.dart';
import 'package:yumi/shared/business_logic/models/res/sc_prop_coupon_list_res.dart';
import 'package:yumi/shared/business_logic/models/res/sc_prop_coupon_record_list_res.dart';
import 'package:yumi/shared/business_logic/models/res/sc_public_message_page_res.dart';
import 'package:yumi/shared/business_logic/models/res/room_res.dart'
    hide WearBadge;
import 'package:yumi/shared/business_logic/models/res/sc_rtc_token_res.dart';
import 'package:yumi/shared/business_logic/models/res/sc_task_list_res.dart';
import 'package:yumi/shared/business_logic/models/res/sc_user_counter_res.dart';
import 'package:yumi/shared/business_logic/models/res/sc_user_identity_res.dart';
import 'package:yumi/shared/business_logic/models/res/sc_user_level_exp_res.dart';
import 'package:yumi/shared/business_logic/models/res/sc_user_red_packet_grab_res.dart';
import 'package:yumi/shared/business_logic/models/res/sc_user_red_packet_send_res.dart';
import 'package:yumi/shared/business_logic/models/req/sc_mobile_auth_cmd.dart';
import 'package:yumi/shared/business_logic/models/res/sc_edit_room_info_res.dart';
import 'package:yumi/shared/business_logic/models/res/follow_room_res.dart'
    hide WearBadge;
import 'package:yumi/shared/business_logic/models/res/follow_user_res.dart'
    hide WearBadge;
import 'package:yumi/shared/business_logic/models/res/join_room_res.dart'
    hide WearBadge;
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
import 'package:yumi/shared/business_logic/models/res/message_friend_user_res.dart';
import 'package:yumi/shared/business_logic/models/res/my_room_res.dart';
import 'package:yumi/shared/business_logic/models/res/room_black_list_res.dart';
import 'package:yumi/shared/business_logic/models/res/sc_sign_in_res.dart';
import 'package:yumi/shared/business_logic/models/res/sc_violation_handle_res.dart';
import 'package:yumi/shared/business_logic/repositories/user_repository.dart';
import 'package:yumi/shared/data_sources/sources/remote/net/network_client.dart';
import 'package:yumi/shared/tools/sc_room_profile_cache.dart';

class SCAccountRepository implements SocialChatUserRepository {
  static SCAccountRepository? _instance;

  SCAccountRepository._internal();

  factory SCAccountRepository() {
    return _instance ??= SCAccountRepository._internal();
  }

  @override
  Future<SocialChatLoginRes> getUser(String id) async {
    final result = await http.get(
      "",
      fromJson: (json) => SocialChatLoginRes.fromJson(json),
    );
    return result;
  }

  ///auth/account/create
  @override
  Future<SocialChatLoginRes> regist(
    String type,
    String openId,
    SCUserProfileCmd userProfileCmd, {
    SCMobileAuthCmd? mobileAuthCmd,
    String invitePeople = "",
  }) async {
    var param = {};
    param["type"] = type;
    param["openId"] = openId;
    param["profile"] = userProfileCmd.toJson();
    if (mobileAuthCmd != null) {
      param["mobile"] = mobileAuthCmd.toJson();
    }
    if (invitePeople.isNotEmpty) {
      param["invitePeople"] = invitePeople;
    }
    final result = await http.post(
      "aa35848b37e5ba74d93e5a1f719c579cb289b5940c15040473b6f57550de35df",
      data: param,
      fromJson: (json) => SocialChatLoginRes.fromJson(json),
    );
    return result;
  }

  ///auth/account/login
  @override
  Future<SocialChatLoginRes> loginForAccount(String account, String pwd) async {
    final result = await http.post<SocialChatLoginRes>(
      "e64f27b9ba6b37881120f4584a5444a5c684d8491b703d0af953e5cc6a5f4cec",
      data: {"account": account, "pwd": pwd},
      fromJson: (json) => SocialChatLoginRes.fromJson(json),
    );
    return result;
  }

  ///auth/account/login/channel
  @override
  Future<SocialChatLoginRes> loginForChannel(
    String authType,
    String openId,
  ) async {
    final result = await http.post<SocialChatLoginRes>(
      "e64f27b9ba6b37881120f4584a5444a5531a33eb137749a5decad584f58aaa44",
      data: {"authType": authType, "openId": openId},
      fromJson: (json) => SocialChatLoginRes.fromJson(json),
    );
    return result;
  }

  ///room/relation/follow
  @override
  Future<List<FollowRoomRes>> followRoomList({String? lastId}) async {
    Map<String, dynamic> param = {};
    if (lastId != null) {
      param["lastId"] = lastId;
    }
    final result = await http.get(
      "59a548c91daed73d9becdf4eba7daf628ba84731fa88da5433b944ca2e6d6098",
      queryParams: param,
      fromJson:
          (json) =>
              (json as List).map((e) => FollowRoomRes.fromJson(e)).toList(),
    );
    return result.map(SCRoomProfileCache.applyToFollowRoomRes).toList();
  }

  ///room/relation/joined
  @override
  Future<List<FollowRoomRes>> joined() async {
    final result = await http.get(
      "06ff6a670e789a391a7af40ce5d6b15c326060e4bcd797edd258ca1d8bb139be",
      fromJson:
          (json) =>
              (json as List).map((e) => FollowRoomRes.fromJson(e)).toList(),
    );
    return result.map(SCRoomProfileCache.applyToFollowRoomRes).toList();
  }

  ///room/relation/trace
  @override
  Future<List<FollowRoomRes>> trace({String? lastId}) async {
    Map<String, dynamic> param = {};
    if (lastId != null) {
      param["lastId"] = lastId;
    }
    final result = await http.get(
      "95523e566901192267301b47f35adc8d5de33f03aaf96911b1a0c8131b938f28",
      queryParams: param,
      fromJson:
          (json) =>
              (json as List).map((e) => FollowRoomRes.fromJson(e)).toList(),
    );
    return result.map(SCRoomProfileCache.applyToFollowRoomRes).toList();
  }

  ///room/profile
  @override
  Future<MyRoomRes> myProfile() async {
    final result = await http.get(
      "1e41384e55cbd6c2374608b129e2ed27",
      fromJson: (json) => MyRoomRes.fromJson(json),
    );
    return SCRoomProfileCache.applyToMyRoomRes(result);
  }

  ///room/live-voice/create
  @override
  Future<SocialChatRoomRes> createRoom() async {
    final result = await http.post(
      "363603111e51beac2d183014dd29b81cf01ca103e12cc332b59b5a8e39c778ec",
      fromJson: (json) => SocialChatRoomRes.fromJson(json),
    );
    return result;
  }

  ///room/live-voice/entry
  @override
  Future<JoinRoomRes> entryRoom(
    String roomId, {
    String? pwd,
    String redPackId = "",
    bool needOpenRedenvelope = false,
  }) async {
    var param = {};
    param["roomId"] = roomId;
    if (pwd != null) {
      param["pwd"] = pwd;
    }
    //自定义字段，用来在输入密码框api拦截时获取
    param["needOpenRedenvelope"] = needOpenRedenvelope;
    param["redPackId"] = redPackId;
    final result = await http.post(
      "363603111e51beac2d183014dd29b81c219577507bcc9c6abfaf327548fed0e0",
      data: param,
      fromJson: (json) => JoinRoomRes.fromJson(json),
    );
    return SCRoomProfileCache.applyToJoinRoomRes(result);
  }

  ///live/user/heartbeat
  @override
  Future heartbeat(String status, bool upMick, {String? roomId}) async {
    var parm = {};
    parm["status"] = status;
    parm["upMick"] = upMick;
    parm["task"] = true;
    if (roomId != null) {
      parm["sessionId"] = roomId;
    }
    final result = await http.post(
      "58f9485b5b9f401c6a14bc1e6534122c7a085bb5f6a613094188ca56fe8bc03d",
      data: parm,
      fromJson: (json) => {},
    );
    return result;
  }

  ///external/im-trtc/tmp/agora/sig
  @override
  Future<SCRtcTokenRes> getRtcToken(String channel, String userId) async {
    final result = await http.get(
      "2572c69d25a0946b0cb35b24bdfcd61c9bcef4afdaced7dfc47a641bd9584f96",
      queryParams: {"channelName": channel, "userId": userId},
      fromJson: (json) => SCRtcTokenRes.fromJson(json),
    );
    return result;
  }

  ///live/room/quit
  @override
  Future<bool> quitRoom(String roomId) async {
    final result = await http.get<bool>(
      "3e451c31ab651a577a3b7796b32041e7",
      queryParams: {"roomId": roomId},
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///room/profile
  @override
  Future<SCEditRoomInfoRes> editRoomInfo(
    String roomId,
    String roomCover,
    String roomName,
    String roomDesc,
    String event,
  ) async {
    final payload = {
      "id": roomId,
      "roomId": roomId,
      "roomCover": roomCover,
      "cover": roomCover,
      "roomName": roomName,
      "roomDesc": roomDesc,
      "event": event,
    };
    debugPrint("[Room Cover Save] request payload=$payload");
    final result = await http.put(
      "1e41384e55cbd6c2374608b129e2ed27",
      data: payload,
      fromJson: (json) => SCEditRoomInfoRes.fromJson(json),
    );
    debugPrint("[Room Cover Save] response=${result.toJson()}");
    await SCRoomProfileCache.saveRoomProfile(
      roomId: roomId,
      roomCover: roomCover,
      roomName: roomName,
      roomDesc: roomDesc,
    );
    return result;
  }

  ///user/user-profile
  @override
  Future<SocialChatUserProfile> loadUserInfo(String userId) async {
    final result = await http.get(
      "2fa1d4f56bb726558904ce2a50b83f961e1cf9b945681bdfb3d4cf7a5ecfc943",
      queryParams: {"userId": userId},
      fromJson: (json) => SocialChatUserProfile.fromJson(json),
    );
    return result;
  }

  ///room/relation/follow/action
  @override
  Future<bool> followRoom(String roomId) async {
    final result = await http.post<bool>(
      "59a548c91daed73d9becdf4eba7daf6226c857599fe196e293c826f60146fa9f",
      data: {"roomId": roomId},
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/support-relation/follow
  @override
  Future<bool> followUser(String userId) async {
    final result = await http.post<bool>(
      "5ee2ca437d883bcd9a4030c44b20b059555c9f831613c06da141d92ffef9d8b7",
      data: {"userId": userId},
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///team/heartbeat
  @override
  Future anchorHeartbeat(String roomId) async {
    final result = await http.get(
      "d28c7d4eeb945fb765c8206c8f79d77f",
      queryParams: {"roomId": roomId},
      fromJson: (json) => {},
    );
    return result;
  }

  ///wallet/gold/balance
  @override
  Future<double> balance() async {
    final result = await http.get<double>(
      "6e864e3aa03c0c398fa2d8f909d21aef2f0b7f5a6a5c523c28407ff12d872b31",
      fromJson: (json) => json as double,
    );
    return result;
  }

  ///user/user-profile/search
  @override
  Future<SocialChatUserProfile> searchUser(String account) async {
    final result = await http.get<SocialChatUserProfile>(
      "2fa1d4f56bb726558904ce2a50b83f9604b0c834cdef3e5a6c3f81b198ab9a4b",
      queryParams: {"account": account},
      fromJson: (json) => SocialChatUserProfile.fromJson(json),
    );
    return result;
  }

  ///user/account/account-pwd-reset
  @override
  Future pwdReset(String pwd) async {
    final result = await http.post(
      "745ce65f1d68f106702ad3c636aca0e0ac57f82127b3ac414551924946593db7",
      data: {"pwd": pwd},
      fromJson: (json) => null,
    );
    return result;
  }

  ///user/user-auth-type/account-is-bind
  @override
  Future<bool> accountIsBind() async {
    final result = await http.get<bool>(
      "0bc43bb5ac93dd30919c4a7c3bbd60335894d3a279a24600c6a7e5dc9536f0e10e634626c0d4977d4df50adfb36c576e",
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/user-auth-type/account-bind
  @override
  Future<bool> bind(String pwd) async {
    final result = await http.post(
      "0bc43bb5ac93dd30919c4a7c3bbd6033963c952c9eca882afb1a172894887db3574aff257ce7e668d08f4caccd1c6232",
      data: {"pwd": pwd},
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/user-auth-type/account-update
  @override
  Future<bool> updatePwd(String pwd, String oldPwd) async {
    final result = await http.post(
      "0bc43bb5ac93dd30919c4a7c3bbd60336a92ac11dbc1fb082f877af0c807bf9f6ad9a4bc80736146ebc083f857e42b4f",
      data: {"pwd": pwd, "oldPwd": oldPwd},
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///room/blacklist
  @override
  Future<List<RoomBlackListRes>> roomBlacklist(
    String roomId,
    String lastId,
  ) async {
    Map<String, dynamic> parm = {};
    parm["roomId"] = roomId;
    if (lastId != "0") {
      parm["lastId"] = lastId;
    }
    final result = await http.get<List<RoomBlackListRes>>(
      "9ce0dac3a29735467208f19ed4edc330",
      queryParams: parm,
      fromJson:
          (json) =>
              (json as List).map((e) => RoomBlackListRes.fromJson(e)).toList(),
    );
    return result;
  }

  ///user/user-profile/update
  @override
  Future<SocialChatUserProfile> updateUserInfo({
    String? userAvatar,
    String? userNickname,
    num? userSex,
    num? age,
    num? bornYear,
    num? bornMonth,
    num? bornDay,
    String? countryId,
    String? hobby,
    String? autograph,
    List<String>? backgroundPhotos,
    List<String>? personalPhotos,
  }) async {
    Map<String, dynamic> parm = {};
    if (userAvatar != null) {
      parm["userAvatar"] = userAvatar;
    }
    if (userNickname != null) {
      parm["userNickname"] = userNickname;
    }
    if (userSex != null) {
      parm["userSex"] = userSex;
    }

    if (age != null) {
      parm["age"] = age;
    }

    if (bornYear != null) {
      parm["bornYear"] = bornYear;
    }

    if (bornMonth != null) {
      parm["bornMonth"] = bornMonth;
    }
    if (bornDay != null) {
      parm["bornDay"] = bornDay;
    }
    if (countryId != null) {
      parm["countryId"] = countryId;
    }
    if (hobby != null) {
      parm["hobby"] = hobby;
    }
    if (autograph != null) {
      parm["autograph"] = autograph;
    }
    if (backgroundPhotos != null) {
      parm["backgroundPhotos"] = backgroundPhotos;
    }
    if (personalPhotos != null) {
      parm["personalPhotos"] = personalPhotos;
    }

    final result = await http.put<SocialChatUserProfile>(
      "2fa1d4f56bb726558904ce2a50b83f96365e62b6aa808acde7b56d2d5945fbe4",
      data: parm,
      fromJson: (json) => SocialChatUserProfile.fromJson(json),
    );
    return result;
  }

  ///user/support-relation/follow/my-list
  @override
  Future<List<FollowUserRes>> followMyList({
    String? account,
    String? lastId,
  }) async {
    Map<String, dynamic> parm = {};
    if (account != null) {
      parm["account"] = account;
    }
    if (lastId != null) {
      parm["lastId"] = lastId;
    }
    final result = await http.get<List<FollowUserRes>>(
      "5ee2ca437d883bcd9a4030c44b20b059984d86f34396dfa8045aa8afe71cb567bc4a9e8c4704c0f73c085e7ab50e7fdb",
      queryParams: parm,
      fromJson:
          (json) =>
              (json as List).map((e) => FollowUserRes.fromJson(e)).toList(),
    );
    return result;
  }

  ///user/support-relation/fans/my-list
  @override
  Future<List<FollowUserRes>> fansMyList({
    String? account,
    String? lastId,
  }) async {
    Map<String, dynamic> parm = {};
    if (account != null) {
      parm["account"] = account;
    }
    if (lastId != null) {
      parm["lastId"] = lastId;
    }
    final result = await http.get<List<FollowUserRes>>(
      "5ee2ca437d883bcd9a4030c44b20b05995242771a17d74da900d0d3c02debf52397bb180e31856d94bf25d85eb342787",
      queryParams: parm,
      fromJson:
          (json) =>
              (json as List).map((e) => FollowUserRes.fromJson(e)).toList(),
    );
    return result;
  }

  ///wallet/gold/this-month/asset-record
  @override
  Future<List<SCGoldRecordRes>> goldRecord({num? type, String? lastId}) async {
    Map<String, dynamic> parm = {};
    if (type != null) {
      parm["type"] = type;
    }
    if (lastId != null) {
      parm["lastId"] = lastId;
    }
    final result = await http.get<List<SCGoldRecordRes>>(
      "aabf121bb4c193ccceac70586aa16f3b06ad35ecd192416cde0bc922045e1dda68a9458578aa4b21fc86df1010fa2ca2",
      queryParams: parm,
      fromJson:
          (json) =>
              (json as List).map((e) => SCGoldRecordRes.fromJson(e)).toList(),
    );
    return result;
  }

  ///user/support-relation/counter
  @override
  Future<List<SCUserCounterRes>> userCounter(String userId) async {
    Map<String, dynamic> parm = {};
    parm["userId"] = userId;
    final result = await http.get<List<SCUserCounterRes>>(
      "5ee2ca437d883bcd9a4030c44b20b05980e9d6b90837a95599c7f32e68756428",
      queryParams: parm,
      fromJson:
          (json) =>
              (json as List).map((e) => SCUserCounterRes.fromJson(e)).toList(),
    );
    return result;
  }

  ///app/h5/identity
  @override
  Future<SCUserIdentityRes> userIdentity({String? userId}) async {
    Map<String, dynamic> parm = {};
    if (userId != null) {
      parm["userId"] = userId;
    }
    final result = await http.get<SCUserIdentityRes>(
      "d29121f09fa26c45b5322df6de0fc25b",
      queryParams: parm,
      fromJson: (json) => SCUserIdentityRes.fromJson(json),
    );
    return result;
  }

  ///user/user-level/consumption/exp
  @override
  Future<SCUserLevelExpRes> userLevelConsumptionExp(
    String userId,
    String type,
  ) async {
    Map<String, dynamic> parm = {};
    parm["userId"] = userId;
    parm["type"] = type;
    final result = await http.get<SCUserLevelExpRes>(
      "9863061ae38e7d452fdd7f95840a952f2751db44c8c4787063c9ccf1dcd80366",
      queryParams: parm,
      fromJson: (json) => SCUserLevelExpRes.fromJson(json),
    );
    return result;
  }

  ///task/check/in/today
  @override
  Future<bool> checkInToday() async {
    final result = await http.get<bool>(
      "b5908b3dc914a82da088fadf8be59213143ec06ec0fc08a0d7d915f0556e3821",
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///task/check/in/list/award
  @override
  Future<SCSignInRes> sginListAward() async {
    final result = await http.get(
      "acdc80e923fd539da1401826ee3e99169b3b4b9cccf8933804239f0e070c54c7",
      fromJson: (json) => SCSignInRes.fromJson(json),
    );
    return result;
  }

  ///task/check/in/receive
  @override
  Future<int> checkInReceive(String id, String resourceGroupId) async {
    Map<String, dynamic> parm = {};
    parm["id"] = id;
    parm["resourceGroupId"] = resourceGroupId;
    final result = await http.post<int>(
      "cd4f02cf4ef018533e882d3cbb23a6aeaeb1d976c8b96774303e69619d73e630",
      data: parm,
      fromJson: (json) => json as int,
    );
    return result;
  }

  ///team/create
  @override
  Future<bool> teamCreate(String ownUserId) async {
    Map<String, dynamic> parm = {};
    parm["ownUserId"] = ownUserId;
    final result = await http.post<bool>(
      "9d3a59e43ee9cf3729f57abc0c596005",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///public-message/page
  @override
  Future<SCPublicMessagePageRes> publicMessagePage(
    String type,
    num pageNo,
    num pageSize,
  ) async {
    Map<String, dynamic> parm = {};
    parm["type"] = type;
    parm["pageNo"] = pageNo;
    parm["pageSize"] = pageSize;
    final result = await http.get<SCPublicMessagePageRes>(
      "38801b8e4843cf3f040b20e8e7a32554118a90740b43e354a7fdc9ac837e0671",
      queryParams: parm,
      fromJson: (json) => SCPublicMessagePageRes.fromJson(json),
    );
    return result;
  }

  ///user/friend-relation/list
  @override
  Future<List<MessageFriendUserRes>> friendList({String? lastId}) async {
    Map<String, dynamic> parm = {};
    if (lastId != null) {
      parm["lastId"] = lastId;
    }
    final result = await http.get<List<MessageFriendUserRes>>(
      "4aff0909d268eb1d0a7f1ded14d28357d8c0811eb69bd36aaaf7bf3d8bf0e486",
      queryParams: parm,
      fromJson:
          (json) =>
              (json as List)
                  .map((e) => MessageFriendUserRes.fromJson(e))
                  .toList(),
    );
    return result;
  }

  ///user/friend-relation/search
  @override
  Future<List<MessageFriendUserRes>> friendSearch(String account) async {
    Map<String, dynamic> parm = {};
    parm["account"] = account;
    final result = await http.get<List<MessageFriendUserRes>>(
      "4aff0909d268eb1d0a7f1ded14d28357879fc2cee9e8f2051bbaccb8bf07e372",
      queryParams: parm,
      fromJson:
          (json) =>
              (json as List)
                  .map((e) => MessageFriendUserRes.fromJson(e))
                  .toList(),
    );
    return result;
  }

  ///team/invite-message-process
  @override
  Future<bool> inviteHost(String id, String status) async {
    Map<String, dynamic> parm = {};
    parm["id"] = id;
    parm["status"] = status;
    final result = await http.post<bool>(
      "e5989162aa832581f74b9a383248e4b8317f6af14ecd57b0c1e01a5e47e7414d",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///team/bd/invite-message-process
  @override
  Future<bool> inviteAgent(String id, String status) async {
    Map<String, dynamic> parm = {};
    parm["id"] = id;
    parm["status"] = status;
    final result = await http.post<bool>(
      "5e44a26c2a5805a21846bf04cb67a75108fa66d1b5877cd04fb8d1761aa95547",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///team/bd/invite-bd-message-process
  @override
  Future<bool> inviteBD(String id, String status) async {
    Map<String, dynamic> parm = {};
    parm["id"] = id;
    parm["status"] = status;
    final result = await http.post<bool>(
      "bbdc8997a823680923efb54a9d31072eabf7f2c09434925bdc6cd2a847f93dcfba2fafbaede21817c8d7e89774331852",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///team/bd/invite-bdleader-message-process
  @override
  Future<bool> inviteBDLeader(String id, String status) async {
    Map<String, dynamic> parm = {};
    parm["id"] = id;
    parm["status"] = status;
    final result = await http.post<bool>(
      "bbdc8997a823680923efb54a9d31072eb14922cefad1be12ebcebd874a66585c7f7f07aa8fdbecc97b3d68d3389dd470",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///team/bd/invite-recharge-agent-message-process
  @override
  Future<bool> inviteRechargeAgent(String id, String status) async {
    Map<String, dynamic> parm = {};
    parm["id"] = id;
    parm["status"] = status;
    final result = await http.post<bool>(
      "771f90aeda269f6e1eb1421f4335c8bf02f5ada0ff7a70fca49e8b367fd079ffd991f48d7a7af790a9593ff2caf1f6fc",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/support-relation/follow/check
  @override
  Future<bool> followCheck(String userId) async {
    Map<String, dynamic> parm = {};
    parm["userId"] = userId;
    final result = await http.get<bool>(
      "5ee2ca437d883bcd9a4030c44b20b059cda65c203d085b6a0dc3eb6c86372454b6de76cbe76f15fa0a33e1759219198c",
      queryParams: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/support-relation/follow-new
  @override
  Future<bool> followNew(String userId) async {
    Map<String, dynamic> parm = {};
    parm["userId"] = userId;
    final result = await http.post<bool>(
      "5ee2ca437d883bcd9a4030c44b20b059787556c9e7c91af11f63f466fc47a7a6574aff257ce7e668d08f4caccd1c6232",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///app/v2/task/list
  @override
  Future<List<SCTaskListRes>> tasks() async {
    final result = await http.get<List<SCTaskListRes>>(
      "6e87048da643aa0388a9e46ea391daff574aff257ce7e668d08f4caccd1c6232",
      fromJson:
          (json) =>
              (json as List).map((e) => SCTaskListRes.fromJson(e)).toList(),
    );
    return result;
  }

  ///app/v2/task/reward
  @override
  Future<bool> taskReward(num taskId) async {
    Map<String, dynamic> parm = {};
    parm["taskId"] = taskId;
    final result = await http.get<bool>(
      "0047abf8502867ed03180e3a6b505d411832ea9bebe4ec426a7036c865082475",
      queryParams: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/support-relation/visitor/list
  @override
  Future<List<FollowUserRes>> visitorList(num pageNumber) async {
    Map<String, dynamic> parm = {};
    parm["pageNumber"] = pageNumber;
    final result = await http.get<List<FollowUserRes>>(
      "5ee2ca437d883bcd9a4030c44b20b05903ab400c9bf27c42312a7e75b67b25a0397bb180e31856d94bf25d85eb342787",
      queryParams: parm,
      fromJson:
          (json) =>
              (json as List).map((e) => FollowUserRes.fromJson(e)).toList(),
    );
    return result;
  }

  ///prop/coupon/list
  @override
  Future<SCPropCouponListRes> propCouponList(
    num size,
    num current, {
    int? couponType,
  }) async {
    Map<String, dynamic> parm = {};
    parm["size"] = size;
    parm["current"] = current;
    if (couponType != null) {
      parm["couponType"] = couponType;
    }
    final result = await http.post<SCPropCouponListRes>(
      "c05bb66ab1d14464aa75f1842e222ce0574aff257ce7e668d08f4caccd1c6232",
      data: parm,
      fromJson: (json) => SCPropCouponListRes.fromJson(json),
    );
    return result;
  }

  ///prop/coupon/record/list
  @override
  Future<SCPropCouponRecordListRes> couponRecordList(
    num size,
    num current, {
    int? couponType,
    int? status,
  }) async {
    Map<String, dynamic> parm = {};
    parm["size"] = size;
    parm["current"] = current;
    if (couponType != null) {
      parm["couponType"] = couponType;
    }
    if (status != null) {
      parm["status"] = status;
    }
    final result = await http.post<SCPropCouponRecordListRes>(
      "0348972fba6d4c510c1860e435c3f68297e6790742d0344ce6b20c597ee86fd1",
      data: parm,
      fromJson: (json) => SCPropCouponRecordListRes.fromJson(json),
    );
    return result;
  }

  ///prop/coupon/use
  @override
  Future<bool> couponUse(String couponNo) async {
    Map<String, dynamic> parm = {};
    parm["couponNo"] = couponNo;
    final result = await http.post<bool>(
      "6163f60d541d3361be0d3f8ef816fc1d",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///prop/coupon/create
  @override
  Future<bool> couponSend(String couponNo, String receiverId) async {
    Map<String, dynamic> parm = {};
    parm["couponNo"] = couponNo;
    parm["receiverId"] = receiverId;
    final result = await http.post<bool>(
      "431750258fbc9a54a3298bf431007fd56ad9a4bc80736146ebc083f857e42b4f",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/badge/own/list
  @override
  Future<List<WearBadge>> badgeOwnList(String type) async {
    Map<String, dynamic> parm = {};
    parm["type"] = type;
    final result = await http.get<List<WearBadge>>(
      "2d234c6012ceaca8dbd3923bb17b2adaf13e23fb57376accca26ee78f1baa860",
      queryParams: parm,
      fromJson:
          (json) => (json as List).map((e) => WearBadge.fromJson(e)).toList(),
    );
    return result;
  }

  ///user/badge/toggle
  @override
  Future<bool> badgeToggle(String badgeId) async {
    Map<String, dynamic> parm = {};
    parm["badgeId"] = badgeId;
    final result = await http.post<bool>(
      "84169ec3c928dde3a22cb4b7b6ae95c31e1cf9b945681bdfb3d4cf7a5ecfc943",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user-violation/handle
  @override
  Future<SCViolationHandleRes> userViolationHandle(
    String userId,
    int violationType,
    int operationType,
    String description, {
    List<String>? imageUrls,
  }) async {
    Map<String, dynamic> parm = {};
    parm["userId"] = userId;
    parm["violationType"] = violationType;
    parm["operationType"] = operationType;
    parm["description"] = description;
    if (imageUrls != null && imageUrls.isNotEmpty) {
      parm["screenshotUrls"] = imageUrls;
    }
    final result = await http.post<SCViolationHandleRes>(
      "cc84151e5fba2824710e0645046729a06f894acdcdbac7ccb7e88e9d69ee3eff",
      data: parm,
      fromJson: (json) => SCViolationHandleRes.fromJson(json),
    );
    return result;
  }

  ///user/cp-relationship/create-apply
  @override
  Future<bool> cpRelationshipSendApply(String acceptApplyUserId) async {
    Map<String, dynamic> parm = {};
    parm["acceptApplyUserId"] = acceptApplyUserId;
    final result = await http.post<bool>(
      "b06a43ca828553e84580a84da4a3af6135e967dbd0d9edde6478905c4b167fd37b53dae821c941c8c13570fbc26665ba",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/cp-relationship/process-apply
  @override
  Future<bool> cpRelationshipProcessApply(String applyId, bool agree) async {
    Map<String, dynamic> parm = {};
    parm["applyId"] = applyId;
    parm["agree"] = agree;
    final result = await http.post<bool>(
      "b06a43ca828553e84580a84da4a3af61cb64264b44425ec78a0115bfc976a827fd57dd4d0233d969f8991e901a14e144",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/cp-relationship/dismiss-apply
  @override
  Future<bool> cpRelationshipDismissApply(String cpUserId) async {
    Map<String, dynamic> parm = {};
    parm["cpUserId"] = cpUserId;
    final result = await http.get<bool>(
      "b06a43ca828553e84580a84da4a3af6147b0e44e9311c7615dee77b6c4c425a1fd57dd4d0233d969f8991e901a14e144",
      queryParams: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/friend-relation/check
  @override
  Future<bool> friendRelationCheck(String userId) async {
    Map<String, dynamic> parm = {};
    parm["userId"] = userId;
    final result = await http.get<bool>(
      "4aff0909d268eb1d0a7f1ded14d28357691f1c364e338d7fc3c50cf21be0f908",
      queryParams: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/red-packet/create
  @override
  Future<SCUserRedPacketSendRes> userRedPacketSend(
    String receiverUserId,
    String totalAmount,
  ) async {
    Map<String, dynamic> parm = {};
    parm["receiverUserId"] = receiverUserId;
    parm["totalAmount"] = totalAmount;
    final result = await http.post<SCUserRedPacketSendRes>(
      "69585024cc7ee090d1e29ff7ca160a45f01ca103e12cc332b59b5a8e39c778ec",
      data: parm,
      fromJson: (json) => SCUserRedPacketSendRes.fromJson(json),
    );
    return result;
  }

  ///user/red-packet/detail
  @override
  Future<SCUserRedPacketSendRes> userRedPacketDetail(String packetId) async {
    Map<String, dynamic> parm = {};
    parm["packetId"] = packetId;
    final result = await http.get<SCUserRedPacketSendRes>(
      "69585024cc7ee090d1e29ff7ca160a457f342deecb1b83d2d8429c59146f10f0",
      queryParams: parm,
      fromJson: (json) => SCUserRedPacketSendRes.fromJson(json),
    );
    return result;
  }

  ///user/red-packet/grab
  @override
  Future<SCUserRedPacketGrabRes> userRedPacketGrab(String packetId) async {
    Map<String, dynamic> parm = {};
    parm["packetId"] = packetId;
    final result = await http.post<SCUserRedPacketGrabRes>(
      "69585024cc7ee090d1e29ff7ca160a450b2a61d0ce4f3f4d50875dcc95b640af",
      data: parm,
      fromJson: (json) => SCUserRedPacketGrabRes.fromJson(json),
    );
    return result;
  }

  ///user/blacklist/list
  @override
  Future<List<MessageFriendUserRes>> userBlacklistList({
    String? account,
    String? lastId,
  }) async {
    Map<String, dynamic> parm = {};
    if (account != null) {
      parm["account"] = account;
    }
    if (lastId != null) {
      parm["lastId"] = lastId;
    }
    final result = await http.get<List<MessageFriendUserRes>>(
      "62bd6154ca9eb9207f3e50294ed18035f13e23fb57376accca26ee78f1baa860",
      queryParams: parm,
      fromJson:
          (json) =>
              (json as List)
                  .map((e) => MessageFriendUserRes.fromJson(e))
                  .toList(),
    );
    return result;
  }

  ///user/blacklist/check
  @override
  Future<bool> blacklistCheck(String shieldUserId) async {
    Map<String, dynamic> parm = {};
    parm["shieldUserId"] = shieldUserId;
    final result = await http.post<bool>(
      "66644b702102d48f4284444b05b1200deda65d2aec525e95d29625cf93fa9e45",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/blacklist
  @override
  Future<bool> addUserBlacklist(String shieldUserId) async {
    Map<String, dynamic> parm = {};
    parm["shieldUserId"] = shieldUserId;
    final result = await http.post<bool>(
      "3f6e2326c10aaed6e637ac0d78a20a3b",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/blacklist/cancel
  @override
  Future<bool> deleteUserBlacklist(String shieldUserId) async {
    Map<String, dynamic> parm = {};
    parm["shieldUserId"] = shieldUserId;
    final result = await http.post<bool>(
      "66644b702102d48f4284444b05b1200d13afc33ba8e2ca51c7245d9201b4569d",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///auth/logout
  @override
  Future<bool> logoutAccount() async {
    final result = await http.delete<bool>(
      "814a34263274ff501f4ca9ae76c4aae3",
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///user/vip/ability/update
  @override
  Future<bool> userVipAbilityUpdate({
    String? contactMode,
    bool? kickPrevention,
    bool? mysteriousInvisibility,
    bool? antiBlock,
  }) async {
    Map<String, dynamic> parm = {};
    if (contactMode != null) {
      parm["contactMode"] = contactMode;
    }
    if (kickPrevention != null) {
      parm["kickPrevention"] = kickPrevention;
    }
    if (mysteriousInvisibility != null) {
      parm["mysteriousInvisibility"] = mysteriousInvisibility;
    }
    if (antiBlock != null) {
      parm["antiBlock"] = antiBlock;
    }
    final result = await http.post<bool>(
      "9bad890ecd3a153658cbe38367fcc46f3db9e152c7701ff2e5e1d4261f763895",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }
}
