TKServer
public class TKServer
Undocumented
-
Undocumented
Declaration
Swift
public static let shared: TKServer
-
Custom base URL to use, instead of hitting SkedGo’s default servers directly.
Note
This is persistently saved toUserDefaults
Declaration
Swift
public static var customBaseURL: String? { get set }
-
Base URL to use for server calls when
customBaseURL
is not set and the server calls do not specify aTKRegion
.Declaration
Swift
public static var fallbackBaseURL: URL { get }
-
Your TripGo API key
Declaration
Swift
public var apiKey: String
-
Custom headers to use, passed allong with calls
Declaration
Swift
public var customHeaders: [String : String]?
-
Undocumented
Declaration
Swift
public var userToken: String? { get set }
-
upload(imageData:
AsynchronouscontentType: ) Undocumented
Declaration
Swift
public func upload(imageData: Data, contentType: String) async throws
-
removeImage()
AsynchronousUndocumented
Declaration
Swift
@discardableResult public func removeImage() async -> Int?
-
Undocumented
Declaration
Swift
public static func imageURL(iconFileNamePart: String?, iconType: TKStyleModeIconType? = nil) -> URL?
-
signIn(withCloudKitID:
Asynchronous) Sign the user in using a token from CloudKit, returning the user token.
Note
The token is only retrieved, but not stored. Most likely you’ll next want to call
TKServer.updateUserToken(_:)
.Note
There’s no need to sign-up first. If this is the sign-in attempt an account with no information but the cloud kit ID will be created.
Declaration
Swift
public func signIn(withCloudKitID cloudKitID: String) async throws -> String
Parameters
cloudKitID
The record name of the CloudKit’s user record ID.
Return Value
The user token. Can fail.
-
signIn(withUUID:
Asynchronous) Sign the user in using a UUID, which you might sync using whichever means you prefer.
Note
The token is only retrieved, but not stored. Most likely you’ll next want to call
TKServer.updateUserToken(_:)
.Note
There’s no need to sign-up first. If this is the sign-in attempt an account with no information but the UUID will be created.
Declaration
Swift
public func signIn(withUUID uuid: String) async throws -> String
Parameters
uuid
A UUID of your choosing
Return Value
The user token. Can fail.
-
downloadUserData()
AsynchronousFetches all server-side data for a user, returning it as raw data, which can be turned in a JSON string or file.
Note
Only returns data if a
userToken
was previously set.Declaration
Swift
public func downloadUserData() async throws -> Data
Return Value
Data, if any was available
-
deleteUserDataAndSignOut()
AsynchronousDeletes all server-side data for a user, and also signs them out by resetting the user token
Declaration
Swift
public func deleteUserDataAndSignOut() async throws
-
Undocumented
See moreDeclaration
Swift
public enum HTTPMethod : String, Codable
-
Undocumented
See moreDeclaration
Swift
public enum RequestError : Error
-
Undocumented
See moreDeclaration
Swift
public enum ServerError : Error
-
Undocumented
See moreDeclaration
Swift
public enum RepeatHandler
-
Undocumented
Declaration
Swift
public func hit<Model: Decodable>( _ type: Model.Type, _ method: HTTPMethod = .GET, path: String, parameters: [String: Any]? = nil, headers: [String: String]? = nil, region: TKRegion? = nil, callbackOnMain: Bool = true, completion: @escaping (Int, [String: Any], Result<Model, Error>) -> Void )
-
Undocumented
Declaration
Swift
public func hit( _ method: HTTPMethod = .GET, path: String, parameters: [String: Any]? = nil, headers: [String: String]? = nil, region: TKRegion? = nil, callbackOnMain: Bool = true, completion: @escaping (Int, [String: Any], Result<Data, Error>) -> Void )
-
Undocumented
Declaration
Swift
public func hit<Model: Decodable>( _ type: Model.Type, _ method: HTTPMethod = .GET, url: URL, parameters: [String: Any]? = nil, headers: [String: String]? = nil, decoderConfig: @escaping (JSONDecoder) -> Void = { _ in }, completion: @escaping (Int, [String: Any], Result<Model, Error>) -> Void )
-
Undocumented
Declaration
Swift
public func hit( _ method: HTTPMethod = .GET, url: URL, parameters: [String: Any]? = nil, headers: [String: String]? = nil, completion: @escaping (Int, [String: Any], Result<Data, Error>) -> Void )
-
Undocumented
Declaration
Swift
public func hitSync( _ method: HTTPMethod = .GET, url: URL, parameters: [String: Any]? = nil, timeout: DispatchTimeInterval ) throws -> Data
-
Captures server response with HTTP status code, headers and typed response
See moreDeclaration
Swift
public struct Response<T>
-
hit(_:
Asynchronousurl: parameters: headers: ) Undocumented
Declaration
Swift
public func hit( _ method: HTTPMethod = .GET, url: URL, parameters: [String: Any]? = nil, headers: [String: String]? = nil ) async -> Response<Data>
-
hit(_:
Asynchronouspath: parameters: headers: region: ) Undocumented
Declaration
Swift
public func hit( _ method: HTTPMethod = .GET, path: String, parameters: [String: Any]? = nil, headers: [String: String]? = nil, region: TKRegion? = nil ) async -> Response<Data>
-
hit(_:
Asynchronous_: path: parameters: headers: region: ) Undocumented
Declaration
Swift
public func hit<Model: Decodable>( _ type: Model.Type, _ method: HTTPMethod = .GET, path: String, parameters: [String: Any]? = nil, headers: [String: String]? = nil, region: TKRegion? = nil ) async -> Response<Model>
-
Undocumented
Declaration
Swift
public func hit<Input: Encodable, Output: Decodable>( _ type: Output.Type, _ method: HTTPMethod = .POST, path: String, input: Input, headers: [String: String]? = nil, region: TKRegion? = nil, encoderConfig: (JSONEncoder) -> Void = { _ in }, decoderConfig: (JSONDecoder) -> Void = { _ in } ) async throws -> Response<Output>
-
hit(_:
Asynchronous_: url: parameters: headers: decoderConfig: ) Undocumented
Declaration
Swift
public func hit<Model: Decodable>( _ type: Model.Type, _ method: HTTPMethod = .GET, url: URL, parameters: [String: Any]? = nil, headers: [String: String]? = nil, decoderConfig: (JSONDecoder) -> Void = { _ in } ) async -> Response<Model>