Questrade API written in Swift.

Overview

QuestradeAPI

Getting Started

The QuestAPI is made up of two main concepts:

  1. ResponseProviders
  2. API

ResponseProviders

The job of the provider is to return data to API for a given request. QuestradeAPI comes with two providers, AuthProvider and FakeDataProvider. You can conform to ResponseProvider and build your own providers if you have extra custom behaviour that you need. To use a given provider just pass the provider to the initilization of API.

let api = API(provider: CustomProvider())

AuthProvider

The AuthProvider class requires a class or struct that conforms to Storable. The purpose of AuthProvider is for authorizing and deauthorizing requests for the API.

let auth = AuthProvider(tokenStore: TokenStore())

Token Store

The Storable protocol is for you to conform to so that you can choose how to securly store the api token.

class TokenStore: Storable {
    // func get() -> Data
    // func set(_ data: Data)
    // func delete()
}

FakeDataProvider

A ResponseProvider that loads fake responses from json files and supplies them as responses. This provider is used by default for API if none is provided on init.

API

The API class can be initilized with or without an authorizer(AuthProvider). If no authorizor is supplied on initilization, a default of FakeDataProvider will be used.

let api = API(provider: auth)

api.accounts { res in
    switch res {
    case .failure(let error): // log error
    case .success(let actResponse):
        let accounts = actResponse.accounts
    }
}

Full Init Code

class MyAPI {

    let loginLink = URL.questAuthURL(
        clientId: "aFsd42sf234FGsdf",
        callbackURL: URL(string: "https://myurl.com/auth-redirect")!
    )
    
    let authProvider = AuthProvider(tokenStore: TokenStore())
    lazy var api: API = { API(provider: authProvider) }()
    
    private(set) var accounts: Set<Account> = []
    
    init() {
        authProvider.delegate = self
    }

    func singIn() {
        // present loginLink
        // user goes through oAuth steps
        // once steps are completed 
        // recieve url from quests oAuth and pass to the authorize from url method.
        authProvider.authorize(from: url)
    }
    
}

extension MyAPI: AuthProviderDelegate {
    func didAuthorize(_ auth: AuthProvider){
        api.accounts{ res in
            do {
                self.accounts.update(try res.get().accounts)
            } catch {
                //TODO: handle error
            }
        }
    }
}

Author

License

This project is licensed under the MIT License - see the LICENSE.md file for details

You might also like...
A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1
A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1

STTwitter A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1 Like a FOSS version of Twitter Fabric TwitterKit, without th

Twitter API for Cocoa developers

FHSTwitterEngine Twitter API for Cocoa developers Created by Nathaniel Symer FHSTwitterEngine can: Authenticate using OAuth and/or xAuth. Make a reque

Giphy API client for iOS in Objective-C

Giphy-iOS Giphy-iOS is a Giphy API client for iOS in Objective-C. Usage To run the example project, clone the repo, and run pod install from the Examp

An easy-to-use Objective-C wrapper for the Uber API (no longer supported)
An easy-to-use Objective-C wrapper for the Uber API (no longer supported)

UberKit UberKit is a simple Objective-C wrapper for the new Uber API . Installation Cocoapods UberKit is available through Cocoapods. To install it, s

Unofficial Dribbble iOS wrapper allows you to integrate Dribble API into iOS application (Designer, Shot, Comment, User Story, Like, Follow)

DribbbleSDK DribbbleSDK is easy-to-use iOS wrapper for Dribbble SDK. We're working hard to complete the full coverage of available methods and make th

ObjectiveFlickr, a Flickr API framework for Objective-C

ObjectiveFlickr ObjectiveFlickr is a Flickr API framework designed for Mac and iPhone apps. OAuth Support ObjectiveFlickr now supports Flickr's new OA

Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging.
Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging.

Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging. Included services are Dropbox, Google Drive, OneDrive, OneDrive for Business, Box, Egnyte, PayPal, Stripe, Google Places, Foursquare, Yelp, YouTube, Vimeo, Twitch, Facebook Messenger, Telegram, Line, Viber, Facebook, GitHub, Google+, LinkedIn, Slack, Twitter, Windows Live, Yahoo, Mailjet, Sendgrid, Twilio, Nexmo, Twizo.

Easy and powerful way to interact with VK API for iOS and macOS
Easy and powerful way to interact with VK API for iOS and macOS

Easy and powerful way to interact with VK API for iOS and macOS. Key features 😊 It's not ios-vk-sdk 😊 🍏 One library for iOS and mac OS 🍏 🀘 Fully

An API wrapper for bitFlyer.

SwiftFlyer An API wrapper for bitFlyer that supports all providing API. API Document https://lightning.bitflyer.jp/docs Usage Public API Fetch a marke

Owner
Eli Slade
I love designing, building and testing digital products.
Eli Slade
Instagram API client written in Swift

SwiftInstagram is a wrapper for the Instagram API written in Swift. It allows you to authenticate users and request data from Instagram effortlessly.

Ander Goig 579 Dec 31, 2022
Wanikani-swift - Unofficial Swift client for the WaniKani API

WaniKani A Swift library and client for the WaniKani REST API. It currently supp

Aaron Sky 5 Oct 28, 2022
A Swift wrapper for Foursquare API. iOS and OSX.

Das Quadrat Das Quadrat is Foursquare API wrapper written in Swift. Features Supports iOS and OSX. Covers all API endpoints. Authorization process imp

Constantine Fry 171 Jun 18, 2022
Unofficial GitHub API client in Swift

Github.swift ❀️ Support my apps ❀️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut

Khoa 184 Nov 25, 2022
A swift SDK for Medium's OAuth2 API

Medium SDK - Swift A library to allow access to Medium API for any Swift iOS application. Features Medium.com authorization & token handling Login sta

null 11 Jan 22, 2022
Swift Wrapper For Bittrex API

BittrexApiKit Swift client for Bittrex api. It support all APIs with most recent changes. more info here let api = Bittrex(apikey: "api key", secretke

Saeid 8 Apr 5, 2021
A Slack API Client for the Perfect Server-Side Swift Framework

PerfectSlackAPIClient is an API Client to access the Slack API from your Perfect Server Side Swift application. It is build on top of PerfectAPIClient

Cap.ι›ͺγƒŽδΈ‹ε…«εΉ‘ 2 Dec 1, 2019
A Swift library for the Forecast.io Dark Sky API

Requirements To use ForecastIO, all you need is an API key for the Dark Sky API. ForecastIO supports iOS (β‰₯9.0), macOS (β‰₯10.10), watchOS (β‰₯2.0), and t

Satyam Ghodasara 163 Jul 26, 2022
Endless-Api-OP - A swift server for Endless

Endless-Api Introduce Hear is endless-api open source library. Endless-Api is us

Underthestars-zhy 1 Jan 30, 2022
The best way to use the Zora API in your Swift projects.

ZoraKit The best way to use the Zora API in your Swift projects. Disclaimer This is still very much a work in progress, and is really a proof-of-conce

MBLA 6 Sep 23, 2022