import 'package:yumi/shared/business_logic/models/res/sc_room_theme_list_res.dart';

import 'package:yumi/shared/business_logic/models/res/bags_list_res.dart';
import 'package:yumi/shared/business_logic/models/res/store_list_res.dart';
import 'package:yumi/shared/business_logic/repositories/store_repository.dart';
import 'package:yumi/shared/data_sources/sources/remote/net/network_client.dart';

class SCStoreRepositoryImp implements SocialChatStoreRepository {
  ///material/props-store/list
  @override
  Future<List<StoreListRes>> storeList(
    String currencyType,
    String propsType,
  ) async {
    Map<String, dynamic> parm = {};
    parm["currencyType"] = currencyType;
    parm["propsType"] = propsType;
    final result = await http.get<List<StoreListRes>>(
      "cfa25ffa98eedd1fe4e0c0466e0aadba85e4421b482ce9dd58a9f96d51f5a577",
      queryParams: parm,
      fromJson:
          (json) =>
              (json as List).map((e) => StoreListRes.fromJson(e)).toList(),
    );
    return result;
  }

  ///material/props-store/purchasing
  @override
  Future<double> storePurchasing(
    String propsId,
    String type,
    String currencyType,
    String days, {
    String? acceptUserId,
  }) async {
    Map<String, dynamic> parm = {};
    parm["propsId"] = propsId;
    parm["type"] = type;
    parm["currencyType"] = currencyType;
    parm["days"] = days;
    if (acceptUserId != null) {
      parm["acceptUserId"] = acceptUserId;
    }
    final result = await http.post<double>(
      "cfa25ffa98eedd1fe4e0c0466e0aadba34acc7c71f29c8b833f6bb11b09789c9",
      data: parm,
      fromJson: (json) => json as double,
    );
    return result;
  }

  ///material/props-store/backpack
  @override
  Future<List<BagsListRes>> storeBackpack(String userId, String type) async{
    Map<String, dynamic> parm = {};
    parm["userId"] = userId;
    parm["type"] = type;
    final result = await http.get<List<BagsListRes>>(
      "cfa25ffa98eedd1fe4e0c0466e0aadba7ae183d89168d8fafbd3be51ed693f3b",
      queryParams: parm,
      fromJson:
          (json) =>
          (json as List).map((e) => BagsListRes.fromJson(e)).toList(),
    );
    return result;
  }

  ///material/props-store/switch-use
  @override
  Future<bool> switchPropsUse(String type, String propsId, bool unload) async{
    Map<String, dynamic> parm = {};
    parm["type"] = type;
    parm["propsId"] = propsId;
    parm["unload"] = unload;
    final result = await http.post<bool>(
      "cfa25ffa98eedd1fe4e0c0466e0aadba840b6522b1ce781d9917b065f1fa7724",
      data: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///room/theme/customize/latest
  @override
  Future<SCRoomThemeListRes> themeCustomizeLatest() async{
    final result = await http.get<SCRoomThemeListRes>(
      "dffae19fd5bf021ce728384106772e22854a7fa69c4cb0a234128de26618a9f2",
      fromJson: (json) => SCRoomThemeListRes.fromJson(json),
    );
    return result;
  }

  ///room/theme/backpack
  @override
  Future<List<SCRoomThemeListRes>> roomThemeBackpack() async{
    final result = await http.get<List<SCRoomThemeListRes>>(
      "6056121c48cba2c743ed6d2c235403a22826cd0a280582ee3ae7bfc4b1ce7391",
      fromJson:
          (json) =>
          (json as List).map((e) => SCRoomThemeListRes.fromJson(e)).toList(),
    );
    return result;
  }

  ///room/theme/switch-use
  @override
  Future<bool> themeSwitchUse(String themeId, bool unload) async{
    Map<String, dynamic> parm = {};
    parm["themeId"] = themeId;
    parm["unload"] = unload;
    final result = await http.get<bool>(
      "1af2a817cf106ccd65b9499d0b6987dfaa528b33bc4166e3f8db18f674507134",
      queryParams: parm,
      fromJson: (json) => json as bool,
    );
    return result;
  }

  ///room/theme/customize
  @override
  Future<double> roomThemeCustomize(String themeUrl) async{
    Map<String, dynamic> parm = {};
    parm["themeUrl"] = themeUrl;
    final result = await http.post<double>(
      "dffae19fd5bf021ce728384106772e2296e9eab98ece5441112164ce0ab9521f",
      data: parm,
      fromJson: (json) => json as double,
    );
    return result;
  }

}
