mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-10 22:45:55 +05:45
* Rename paywallsEventsManager to eventsManager * Rename PaywallEventsManagerType to EventsManagerType * Rename PaywallEventsManager to EventsManager * Rename PaywallEventStore to FeatureEventStore * Rename InternalAPI.postPaywallEvents to postFeatureEvents * Rename StoredEventSerializer to StoredFeatureEventSerializer * Rename createStoredEvent to createFeatureStoredEvent * Rename StoredEvent to StoredFeatureEvent * Rename HTTPRequest.PaywallPath to HTTPRequest.FeatureEventsPath * Rearrange events files * Rename event related files * Extract shared events endpoint configuration to EventsHTTPRequestPath Both FeatureEventsPath and AdPath share the same /v1/events endpoint configuration, differing only in domain (api-paywalls.revenuecat.com vs a.revenue.cat) and name. Extract common logic to EventsHTTPRequestPath protocol in Sources/Events/Networking. * Move Sources/FeatureEvents to Sources/Events/FeatureEvents * Rename EventsRequest to FeatureEventsRequest - Rename EventsRequest.swift to FeatureEventsRequest.swift - Move file to Sources/Events/FeatureEvents/Networking/ - Update all references in source and test files - Update Xcode project file references This makes it clear that this request type is specifically for the feature events endpoint, not a generic events request. * Remove ad events from feature events system Ad events should not be sent through the feature events system as they require their own separate infrastructure with a different API endpoint. Changes: - Remove FeatureEvent conformance from AdEvent - Remove .ads case from Feature enum - Remove ad events handling from FeatureEventsRequest - Add no-op track(adEvent:) method to EventsManager with comment - Update AdTracker to call the new track(adEvent:) method Ad events tracking now becomes a no-op until proper implementation with: - StoredAdEvent structure - AdEventStore for persistence - InternalAPI.postAdEvents() using HTTPRequest.AdPath.postEvents * Rename PostEventsOperation to PostFeatureEventsOperation - Rename PostEventsOperation.swift to PostFeatureEventsOperation.swift - Move file to Sources/Events/FeatureEvents/Networking/ - Update class name and remove misleading "generic" comment - Update references in InternalAPI.swift - Update Xcode project file references This makes it clear that this operation is specifically for posting feature events, not a generic operation for various event types.
124 lines
2.8 KiB
Swift
124 lines
2.8 KiB
Swift
//
|
|
// 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
|
|
//
|
|
// HTTPRequest.swift
|
|
//
|
|
// Created by Nacho Soto on 2/27/22.
|
|
|
|
import Foundation
|
|
|
|
/// A request to be made by ``HTTPClient``
|
|
struct HTTPRequest {
|
|
|
|
typealias Headers = [String: String]
|
|
|
|
var method: Method
|
|
var path: HTTPRequestPath
|
|
/// If present, this will be used by the server to compute a checksum of the response signed with a private key.
|
|
var nonce: Data?
|
|
/// Whether or not this request should be retried by the HTTPClient for certain status codes.
|
|
var isRetryable: Bool
|
|
|
|
init(
|
|
method: Method,
|
|
path: HTTPRequest.Path,
|
|
nonce: Data? = nil,
|
|
isRetryable: Bool = false
|
|
) {
|
|
self.init(method: method, requestPath: path, nonce: nonce, isRetryable: isRetryable)
|
|
}
|
|
|
|
init(
|
|
method: Method,
|
|
path: HTTPRequest.FeatureEventsPath,
|
|
nonce: Data? = nil,
|
|
isRetryable: Bool = false
|
|
) {
|
|
self.init(method: method, requestPath: path, nonce: nonce, isRetryable: isRetryable)
|
|
}
|
|
|
|
init(
|
|
method: Method,
|
|
path: HTTPRequest.DiagnosticsPath,
|
|
nonce: Data? = nil,
|
|
isRetryable: Bool = false
|
|
) {
|
|
self.init(method: method, requestPath: path, nonce: nonce, isRetryable: isRetryable)
|
|
}
|
|
|
|
init(
|
|
method: Method,
|
|
path: HTTPRequest.WebBillingPath,
|
|
nonce: Data? = nil,
|
|
isRetryable: Bool = false
|
|
) {
|
|
self.init(method: method, requestPath: path, nonce: nonce, isRetryable: isRetryable)
|
|
}
|
|
|
|
init(
|
|
method: Method,
|
|
path: HTTPRequest.AdPath,
|
|
nonce: Data? = nil,
|
|
isRetryable: Bool = false
|
|
) {
|
|
self.init(method: method, requestPath: path, nonce: nonce, isRetryable: isRetryable)
|
|
}
|
|
|
|
internal init(
|
|
method: Method,
|
|
requestPath: HTTPRequestPath,
|
|
nonce: Data? = nil,
|
|
isRetryable: Bool = false
|
|
) {
|
|
assert(nonce == nil || nonce?.count == Data.nonceLength,
|
|
"Invalid nonce: \(nonce?.description ?? "")")
|
|
|
|
self.method = method
|
|
self.path = requestPath
|
|
self.nonce = nonce
|
|
self.isRetryable = isRetryable
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Method
|
|
|
|
extension HTTPRequest {
|
|
|
|
enum Method {
|
|
|
|
case get
|
|
case post(HTTPRequestBody)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
extension HTTPRequest {
|
|
|
|
var requestBody: HTTPRequestBody? {
|
|
switch self.method {
|
|
case let .post(body): return body
|
|
case .get: return nil
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension HTTPRequest.Method {
|
|
|
|
var httpMethod: String {
|
|
switch self {
|
|
case .get: return "GET"
|
|
case .post: return "POST"
|
|
}
|
|
}
|
|
|
|
}
|