RateLimit
public struct RateLimit
The RateLimit
struct abstracts any rate-limit information returned from an
Response
.
-
The number of calls allowed for this resource during the refresh period.
Declaration
Swift
public let limit: Int
-
The number of calls remaining for this resource during the current refresh period.
Declaration
Swift
public let remaining: Int
-
The date and time at which the refresh period will reset.
Declaration
Swift
public let resetDate: Date
-
Initializes the struct.
Declaration
Swift
public init(limit: Int, remaining: Int, resetDate: Date)
Parameters
limit
The total number of calls allowed in the rate limit period for the endpoint.
remaining
The number of calls remaining in the rate limit period.
resetDate
The time at which the rate limit will reset.
-
Initializes a new instance from the headers of an API response.
Declaration
Swift
public init?(headers: [AnyHashable : Any])
Parameters
headers
The headers of the API response.
-
Abstracts out the rate-limiting headers from an
URLResponse
and stores their value in a new instance ofRateLimit
.Declaration
Swift
public init?(response: URLResponse?)
Parameters
response
An instance of
URLResponse
.