LNHttpManager+Gift.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // LNHttpManager+Gift.swift
  3. // Gami
  4. //
  5. // Created by OneeChan on 2026/3/24.
  6. //
  7. import Foundation
  8. private let kNetPath_Gift_Resource_List = "/gift/resource/list"
  9. private let kNetPath_Gift_List = "/list/gift/list"
  10. private let kNetPath_Gift_Send = "/list/gift/send"
  11. class LNSendGiftParams {
  12. var roomId: String = ""
  13. var giftId: String = ""
  14. var userIds: [String] = []
  15. var quantity: Int = 0
  16. var seamlessRedeem: Bool = false
  17. fileprivate var toParams: [String: Any] {
  18. [
  19. "roomId": roomId,
  20. "giftId": giftId,
  21. "userIds": userIds,
  22. "quantity": quantity,
  23. "seamlessRedeem": seamlessRedeem
  24. ]
  25. }
  26. }
  27. extension LNHttpManager {
  28. func loadResourceList(version: String, size: Int, next: String,
  29. completion: @escaping (LNGiftResourceListResponse?, LNHttpError?) -> Void) {
  30. post(path: kNetPath_Gift_Resource_List, params: [
  31. "page": [
  32. "size": size,
  33. "next": next
  34. ],
  35. "version": version
  36. ], completion: completion)
  37. }
  38. func loadGiftList(roomId: String, completion: @escaping (LNGiftListResponse?, LNHttpError?) -> Void) {
  39. post(path: kNetPath_Gift_List, params: [
  40. "roomId": roomId,
  41. ], completion: completion)
  42. }
  43. func sendGift(params: LNSendGiftParams, completion: @escaping (LNSendGiftResponse?, LNHttpError?) -> Void) {
  44. post(path: kNetPath_Gift_Send, params: params.toParams, completion: completion)
  45. }
  46. }