WealthsimpleDownloader

public final class WealthsimpleDownloader

Main entry point for the library

  • Callback which is called in case the user needs to authenticate. Needs to return username, password, and one time password

    Declaration

    Swift

    public typealias AuthenticationCallback = (@escaping (String, String, String) -> Void) -> Void
  • Creates the Downloader instance

    After creating, first call the authenticate method.

    Declaration

    Swift

    public init(authenticationCallback: @escaping AuthenticationCallback, credentialStorage: CredentialStorage)

    Parameters

    authenticationCallback

    Callback which is called in case the user needs to authenticate. Needs to return username, password, and one time password. Might be called during any call.

    credentialStorage

    A CredentialStore to save API tokens to. Implementation can be empty, in this case the authenticationCallback will be called every time and not only when the refresh token expired

  • Authneticates against the API. Call before calling any other method.

    Declaration

    Swift

    public func authenticate(completion: @escaping (Error?) -> Void)

    Parameters

    completion

    Gets an error in case something went wrong, otherwise nil

  • Get all Accounts the user has access to

    Declaration

    Swift

    public func getAccounts(completion: @escaping (Result<[Account], AccountError>) -> Void)

    Parameters

    completion

    Result with an array of Accounts or an Account.AccountError

  • Get all Positions from one Account

    Declaration

    Swift

    public func getPositions(in account: Account, date: Date?, completion: @escaping (Result<[Position], PositionError>) -> Void)

    Parameters

    account

    Account to retreive positions for

    date

    Date of which the positions should be downloaded. If not date is provided, not date is sent to the API. The API falls back to the current date.

    completion

    Result with an array of Positions or an Position.PositionError

  • Get all Transactionss from one Account

    Declaration

    Swift

    public func getTransactions(in account: Account, startDate: Date?, completion: @escaping (Result<[Transaction], TransactionError>) -> Void)

    Parameters

    account

    Account to retreive transactions from

    startDate

    Date from which the transactions are downloaded. If not date is provided, not date is sent to the API. The API falls back to 30 days ago from today.

    completion

    Result with an array of Transactionss or an Transactions.TransactionsError