CompassCardDownloader
@available(iOS 14.5, macOS 11.3, *)
public class CompassCardDownloader
Class to download the current balance and transactions from your CompassCard
This class uses a webscraper to login. Your delegate needs to provide a view to add the webview to
-
Delegate for the CompassCardDownloader
Declaration
Swift
public weak var delegate: CompassCardDownloaderDelegate?
-
Creates an instance of the CompassCardDownloader
Declaration
Swift
public init()
-
Logs into the Compass Card website and reads the current balance
Note: If you want to call this function multiple times, be aware that it will request a view every time
Declaration
Swift
public func authorizeAndGetBalance(email: String, password: String, _ completion: @escaping (Result<(String, String), Error>) -> Void)
Parameters
email
email adress to login
password
password to login
completion
completion handler - receives result of card number and balance
-
Downloads the transactions for the card
Note: you need to call this function after
authorizeAndGetBalance
as only this one adds the webview to the view from the delegateDeclaration
Swift
public func downloadCardTransactions(cardNumber: String, dateToLoadFrom: Date, _ completion: @escaping (Result<String, Error>) -> Void)
Parameters
dateToLoadFrom
Date which will be passed to the API as start date to load transactions
completion
completion handler which returns a string with the CSV result