Skip to content

Commit

Permalink
added RequestStatus enum
Browse files Browse the repository at this point in the history
  • Loading branch information
ab1470 committed Aug 20, 2024
1 parent e6adf68 commit c23fc23
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Sources/KlaviyoSwift/SDKRequestIterator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,23 @@ public struct SDKRequest: Identifiable, Equatable {
}
}

@_spi(KlaviyoPrivate)
public enum RequestStatus {
public enum RequestError: Error {
case requestFailed(Error)
/// The server responded with a 429 HTTP status code, indicating that the client is being rate-limited.
/// - Parameter retryAfter: The amount of time, in seconds, that the client should wait before making another request.
case rateLimited(retryAfter: Int)
/// - Parameter duration: The elapsed time, in seconds, between the API call and the server’s response.
case httpError(statusCode: Int, duration: TimeInterval)
}

case started
/// - Parameter duration: The elapsed time, in seconds, between the API call and the server’s response.
case completed(data: Data, duration: TimeInterval)
case error(RequestError)
}

@_spi(KlaviyoPrivate)
public func requestIterator() -> AsyncStream<SDKRequest> {
AsyncStream<SDKRequest> { continuation in
Expand Down

0 comments on commit c23fc23

Please sign in to comment.