Fixer
struct Fixer
Adds support for requesting data from the Fixer.io Latest Rates API and being provided
with an Exchange instance configured with this data.
Example
Exchange.Fixer.exchange(accessKey: "YourFixerAccessKey") { result in
switch result {
case let .success(exchange):
// We have an Exchange value
case let .failure(error):
// Something went wrong. Dig into the error.
}
}
-
Provides an
Exchangevalue based upon the Fixer.io Latest Rates API.Declaration
Swift
@discardableResult static public func exchange( session: URLSession = .shared, host: String = defaultHost, path: String = detaultAPIPath, secure: Bool = true, accessKey: String?, completion: @escaping FixerCompletion ) -> URLSessionTask?Parameters
sessionA
URLSessionused to create theURLSessionTask. Defaults to URLSession.sharedhostThe host name (domain) of a Fixer.io compatible API. Defaults to the standard Fixer.io data host
pathThe path (domain) to a Fixer.io Latest Rates compatible API. Defaults to the standard Fixer.io Latest Rates API
secureWhether the request should be made over HTTP or HTTPS. The basic Fixer.io plan only supports HTTP. Defaults to true (HTTPS).
accessKeyThe API access key issued by Fixer.io. Optional if you are using a compatible API that does not require an access key.
completionCompletes with a Swift
Result<Exchange, FixerError>type. If theURLSessionTaskis cancelled before completion, then this closure will not get called.Return Value
An optional
URLSessionTaskhandling the network request for the Fixer.io API call. If no call was made, due to error, thennilwill be returned. -
Declaration
Swift
public typealias FixerCompletion = (_ result: Result<Exchange, FixerError>) -> VoidParameters
resultA Swift
Result<Exchange, FixerError>type.
-
The standard Fixer.io host for API calls:
data.fixer.ioDeclaration
Swift
public static let defaultHost: String -
The standard path for the Latest Rates API:
api/latestDeclaration
Swift
public static let detaultAPIPath: String -
The URL query item key used to supply the API access key:
access_keyDeclaration
Swift
public static let accessKeyQueryKey: String
View on GitHub
Install in Dash
Fixer Structure Reference