import Foundation

extension APIClient {
    func providerBillingOverview() async throws -> Data {
        try await request(path: "/provider/billing-overview").0
    }
    func providerPaymentStatus(order: String) async throws -> Data {
        let encoded = order.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? order
        return try await request(path: "/provider/payment-status?order=\(encoded)").0
    }
    func providerPurchaseSubscription(planId: Int, months: Int, method: String, idempotencyKey: String) async throws -> Data {
        let body = try JSONSerialization.data(withJSONObject: ["plan_id": planId, "period_months": months, "payment_method": method])
        return try await request(path: "/provider/subscription-purchase", method: "POST", body: body, idempotencyKey: idempotencyKey).0
    }
    func providerWallet() async throws -> Data {
        try await request(path: "/provider/wallet-mobile").0
    }
    func providerSponsoredListing(days: Int, categoryId: Int = 0, cityId: Int = 0, districtId: Int = 0, idempotencyKey: String) async throws -> Data {
        let body = try JSONSerialization.data(withJSONObject: ["days_count": days, "category_id": categoryId, "city_id": cityId, "district_id": districtId])
        return try await request(path: "/provider/sponsored-listings", method: "POST", body: body, idempotencyKey: idempotencyKey).0
    }
}
