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 to UserDefaults

    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 a TKRegion.

    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 }
  • Undocumented

    Declaration

    Swift

    public func upload(imageData: Data, contentType: String) async throws
  • removeImage() Asynchronous

    Undocumented

    Declaration

    Swift

    @discardableResult
    public func removeImage() async -> Int?
  • Undocumented

    Declaration

    Swift

    public static func imageURL(iconFileNamePart: String?, iconType: TKStyleModeIconType? = nil) -> URL?
  • 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() Asynchronous

    Fetches 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

  • Deletes 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 more

    Declaration

    Swift

    public enum HTTPMethod : String, Codable
  • Undocumented

    See more

    Declaration

    Swift

    public enum RequestError : Error
  • Undocumented

    See more

    Declaration

    Swift

    public enum ServerError : Error
  • Undocumented

    See more

    Declaration

    Swift

    public enum RepeatHandler

Hit (Path)

Hit (URL)

  • 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

Async/await