Latest 0.2.1
Homepage https://github.com/pollarm/MondoKit
License MIT
Platforms ios 9.0, requires ARC
Dependencies SwiftyJSON, SwiftyJSONDecodable, Alamofire, KeychainAccess
Authors

Carthage compatible
CocoaPods Compatible
License
Platform

MondoKit is a Swift framework wrapping the Mondo API at https://getmondo.co.uk/docs/

Requirements

  • iOS 9.0+
  • Xcode 7.2+

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

To integrate MondoKit into your Xcode project using Carthage, specify it in your Cartfile:

github "pollarm/MondoKit"

Run carthage update --platform iOS --no-use-binaries to build the framework and it’s dependencies and drag the built Alamofire.framework, KeychainAccess.framework, SwiftyJSONDecodable.framework, SwiftyJSON.framework and MondoKit.framework into your Xcode project.

CocoaPods

CocoaPods 0.39.0+ is required to build MondoKit.

To integrate MondoKit into your Xcode project using CocoaPods, specify it in your Podfile:

platform :ios, '9.0'
use_frameworks!

pod 'MondoKit'

Then, run the following command:

$ pod install

Getting started

Initialization

Initialising the MondAPI is achieved as follows and should be done before you do anything else with the MondoAPI class, so probably in applicationDidFinishLaunchingWithOptions.

MondoAPI.instance.initialiseWithClientId(mondoClientId, clientSecret : mondoClientSecret)

One option is to store your Mondo clientId and clientSecret in a property list file called MondoKeys.plist (don’t forget to .gitignore this file).
You can then initialise the MondoAPI as follows:

guard let mondoKeysPath = NSBundle.mainBundle().pathForResource("MondoKeys", ofType: "plist"),
    mondoKeys = NSDictionary(contentsOfFile: mondoKeysPath),
    mondoClientId = mondoKeys["clientId"] as? String,
    mondoClientSecret = mondoKeys["clientSecret"] as? String else {

        assertionFailure("MondoKeys.plist containing 'clientId' and 'clientSecret' required but not found in main bundle")
        return false
    }

MondoAPI.instance.initialiseWithClientId(mondoClientId, clientSecret : mondoClientSecret)

Authentication

MondoAPI provides a ViewController implemetation to manage 3-legged authorization with the API. It also stores authorization details (accessToken, expiresIn etc.) securely in the KeyChain in the event of a successful authorization so you don’t need to login every time you run your app.

To check if MondoAPI is already authorized for a user:

if MondoAPI.instance.isAuthorized { ... proceed ... }

If not then request an auth ViewController specifiying the callback closure to deal with the result and present it:

else {
    let oauthViewController = MondoAPI.instance.newAuthViewController() { (success, error) in
        if success {
            self.dismissViewControllerAnimated(true) {
            // proceed now we're logged in
        }
        else {
            // present error to user
        }
    }
    presentViewController(oauthViewController, animated: true, completion: nil)
}

listAccounts

MondoAPI.instance.listAccounts() { (accounts, error) in ... }

getBalanceForAccount

MondoAPI.instance.getBalanceForAccount(account) { (balance, error) in ... }

listTransactions

MondoAPI.instance.listTransactionsForAccount(account) { (transactions, error) in ... }

eg. using Optional expand parameter

MondoAPI.instance.listTransactionsForAccount(account, expand: "merchant") { (transactions, error) in ... }

eg. using Optional pagination parameter

MondoAPI.instance.listTransactionsForAccount(account, pagination: MondoAPI.Pagination(limit: 50, since: .Date(NSDate()), before: NSDate())) { (transactions, error) in ... }

getTransactionForId

MondoAPI.instance.getTransactionForId(id, expand: "merchant") { (transaction, error) in ... }

annotateTransaction

MondoAPI.instance.annotateTransaction(transaction, withKey "aKey", value: "aValue") { (transaction, error) in ... }

listFeedForAccount

MondoAPI.instance.listFeedForAccount(account) { (feedItems, error) in ... }

Latest podspec

{
    "name": "MondoKit",
    "version": "0.2.1",
    "summary": "MondoKit is a Swift framework wrapping the Mondo API at https://getmondo.co.uk/docs/",
    "homepage": "https://github.com/pollarm/MondoKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Mike Pollard": "[email protected]"
    },
    "social_media_url": "http://twitter.com/mikeypollard1",
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/pollarm/MondoKit.git",
        "tag": "0.2.1"
    },
    "source_files": "MondoKit/**/*.{h,swift}",
    "dependencies": {
        "SwiftyJSON": [
            "~> 2.3"
        ],
        "SwiftyJSONDecodable": [
            "~> 0.1"
        ],
        "Alamofire": [
            "~> 3.0"
        ],
        "KeychainAccess": []
    }
}

Pin It on Pinterest

Share This