2025-05-06 15:28:59 -06:00
|
|
|
//
|
|
|
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the MIT License (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
|
//
|
|
|
|
|
// WebBillingHTTPRequestPath.swift
|
|
|
|
|
//
|
|
|
|
|
// Created by Toni Rico on 5/6/25.
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
|
|
extension HTTPRequest.WebBillingPath: HTTPRequestPath {
|
|
|
|
|
|
|
|
|
|
// swiftlint:disable:next force_unwrapping
|
|
|
|
|
static let serverHostURL = URL(string: "https://api.revenuecat.com")!
|
|
|
|
|
|
|
|
|
|
var authenticated: Bool {
|
|
|
|
|
switch self {
|
2025-07-29 18:31:15 +02:00
|
|
|
case .getWebOfferingProducts,
|
|
|
|
|
.getWebBillingProducts:
|
2025-05-06 15:28:59 -06:00
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var shouldSendEtag: Bool {
|
|
|
|
|
switch self {
|
2025-07-29 18:31:15 +02:00
|
|
|
case .getWebOfferingProducts,
|
|
|
|
|
.getWebBillingProducts:
|
2025-05-06 15:28:59 -06:00
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var supportsSignatureVerification: Bool {
|
|
|
|
|
switch self {
|
2025-07-29 18:31:15 +02:00
|
|
|
case .getWebOfferingProducts,
|
|
|
|
|
.getWebBillingProducts:
|
2025-05-06 15:28:59 -06:00
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var needsNonceForSigning: Bool {
|
|
|
|
|
switch self {
|
2025-07-29 18:31:15 +02:00
|
|
|
case .getWebOfferingProducts,
|
|
|
|
|
.getWebBillingProducts:
|
2025-05-06 15:28:59 -06:00
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var relativePath: String {
|
|
|
|
|
switch self {
|
2025-07-23 13:56:20 +02:00
|
|
|
case let .getWebOfferingProducts(appUserID):
|
2025-05-21 04:37:56 -07:00
|
|
|
return "/rcbilling/v1/subscribers/\(appUserID.trimmedAndEscaped)/offering_products"
|
2025-07-29 18:31:15 +02:00
|
|
|
case let .getWebBillingProducts(userId, productIds):
|
|
|
|
|
let encodedUserId = userId.trimmedAndEscaped
|
|
|
|
|
let encodedProductIds = productIds.map { productId in
|
|
|
|
|
"id=\(productId.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? productId)"
|
|
|
|
|
}.joined(separator: "&")
|
|
|
|
|
return "/rcbilling/v1/subscribers/\(encodedUserId)/products?\(encodedProductIds)"
|
2025-05-06 15:28:59 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var name: String {
|
|
|
|
|
switch self {
|
2025-07-23 13:56:20 +02:00
|
|
|
case .getWebOfferingProducts:
|
2025-07-29 18:31:15 +02:00
|
|
|
return "get_web_offering_products"
|
|
|
|
|
case .getWebBillingProducts:
|
2025-05-06 15:28:59 -06:00
|
|
|
return "get_web_products"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|