Zone5
final public class Zone5
The entrance point to the rest of the API. This class encapsulates client configuration, and provides access to the individual endpoints, grouped into views.
-
Shared instance of the Zone5 SDK
Declaration
Swift
public static let shared: Zone5
-
Undocumented
Declaration
Swift
public static let authTokenChangedNotification: Notification.Name
-
Undocumented
Declaration
Swift
public static let updatedTermsNotification: Notification.Name
-
The access token representing the currently authenticated user.
This property automatically captures the token returned by the server when using methods such as
OAuthView.accessToken(username:password:completion:)
, but can also be set using a token that was stored during a previous session.Declaration
Swift
public internal(set) var accessToken: AccessToken? { get set }
-
Undocumented
Declaration
Swift
public var debugLogging: Bool
-
The root URL for the server that we want to communicate with.
Note
This value can be set using theconfigure(for:clientID:clientSecret:)
method.Declaration
Swift
public internal(set) var baseURL: URL? { get }
-
The clientID, as provided by Zone5.
Note
This value can be set using theconfigure(for:clientID:clientSecret:)
method.Declaration
Swift
public internal(set) var clientID: String? { get }
-
The secret key, as provided by Zone5.
Note
This value can be set using theconfigure(for:clientID:clientSecret:)
method.Declaration
Swift
public internal(set) var clientSecret: String? { get }
-
The user agent to set in the User-Agent header
Declaration
Swift
public internal(set) var userAgent: String? { get }
-
Undocumented
Declaration
Swift
public var notificationCenter: NotificationCenter
-
Configures the SDK to use the application specified by the given
clientID
andclientSecret
.Declaration
Swift
public func configure(for baseURL: URL, clientID: String? = nil, clientSecret: String? = nil, userAgent: String? = nil, accessToken: AccessToken?)
Parameters
baseURL
The API url to use.
clientID
The clientID, as provided by Zone5.
clientSecret
The secret key, as provided by Zone5.
accessToken
An access token representing a user authenticated during a previous session. If
nil
, any existing access token will be cleared. -
Configures the SDK to use the application specified by the given
clientID
andclientSecret
.Declaration
Swift
public func configure(for baseURL: URL, clientID: String? = nil, clientSecret: String? = nil, userAgent: String? = nil)
Parameters
baseURL
The API url to use.
clientID
The clientID, as provided by Zone5.
clientSecret
The secret key, as provided by Zone5.
-
Configures the SDK on behalf of a user, represented by the given
accessToken
.As this method does not include the
clientID
orclientSecret
, configuring the SDK this way will not allow for user authentication, and is intended for instances where theaccessToken
is sourced externally, such as through single sign-on.Declaration
Swift
public func configure(for baseURL: URL, accessToken: AccessToken)
Parameters
baseURL
The API url to use.
accessToken
An access token that represents your user and client.
-
Flag that indicates if the receiver has been configured correctly. If the value of this property is
false
, theconfigure(for:clientID:clientSecret:)
orconfigure(for:accessToken:)
methods will need to be called to configure the client for access to the Zone5 API.Declaration
Swift
public var isConfigured: Bool { get }
-
A collection of API endpoints related to activities.
Declaration
Swift
public lazy var activities: ActivitiesView { get set }
-
A collection of API endpoints related to user authentication.
Declaration
Swift
public lazy var oAuth: OAuthView { get set }
-
A collection of API endpoints related to user data.
Declaration
Swift
public lazy var users: UsersView { get set }
-
A collection of API endpoints related to routes.
Declaration
Swift
public lazy var routes: RoutesView { get set }
-
A collection of API endpoints related to metrics.
Declaration
Swift
public lazy var metrics: MetricsView { get set }
-
A collection of API endpoints related to third party connections (like Strava).
Declaration
Swift
public lazy var thirdPartyConnections: ThirdPartyConnectionsView { get set }
-
A collection of API endpoints related to the calling UserAgent
Declaration
Swift
public lazy var userAgents: UserAgentView { get set }
-
A collection of API endpoints related to payments.
Declaration
Swift
public lazy var payments: PaymentsView { get set }
-
A collection of API endpoints related to Terms and Conditions
Declaration
Swift
public lazy var terms: TermsView { get set }
-
A collection of functions to call API endpoints to a server external to Zone5
Declaration
Swift
public lazy var external: ExternalView { get set }
-
Enumeration containing the decoded value on success, or the error that occurred on failure.
Declaration
Swift
public typealias Result<Element> = Swift.Result<Element, Zone5.Error> where Element : Decodable
-
Function that receives a
Result
that can either contain a structure decoded from a server response, or an error if one occurred, typically used for handling the completion of an API call.Declaration
Swift
public typealias ResultHandler<Element> = (_ result: Result<Element>) -> Void where Element : Decodable
Parameters
result
Enumeration containing the decoded value on success, or the error that occurred on failure.
-
Definitions for errors typically thrown by Zone5 methods.
See moreDeclaration
Swift
public enum Error : Swift.Error, CustomDebugStringConvertible
-
Undocumented
See moreDeclaration
Swift
enum Method : String
-
Undocumented
Declaration
Swift
struct VoidReply : Decodable