Giter VIP home page Giter VIP logo

monzo-swift's Introduction

Monzo Swift Client

Swift Linux License Travis Codebeat

A Monzo client that provides a simple Swift interface to the Monzo API. This package is targeted towards server side use on Linux; if you're looking for a Monzo client for iOS then have a look at MondoKit.

API documentation, user guides and setup information can be found at monzo.com/docs.

Installation

Note: the minimum required Swift version is DEVELOPMENT-SNAPSHOT-2016-11-08-a

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/marius-serban/monzo-swift.git"),
    ]
)

Getting started

The library is compatible with Open Swift so you can use it with any server side framework that supports this standards. It relies upon a S4 Responder to perform the HTTP calls over the network. Luckly, Vapor's Droplet and Zewo's' Client conform to this protocol for example.

Initialize your client

let myHttpClient = ...
let monzo = Monzo.Client(httpClient: myHttpClient)

Create authorization URI

Create a URI that points to the Monzo login page for your app.

let uri = Monzo.Client.authorizationUri(clientId: "aClientId", redirectUri: "http://host.com/?param=[]#fragment", nonce: "abc123")
// redirect user to URI

Authenticate

let credentials = try monzo.authenticate(withCode: " ", clientId: " ", clientSecret: " ")

or

let newCredentials = try monzo.refreshAccessToken(refreshToken: oldCredentials.refreshToken, clientId: " ", clientSecret: " ")

Ping

do {
  try monzo.ping()
} catch {
  // try again later
}

Whoami

let accessTokenInfo = try monzo.whoami(accessToken: "a_token")

Accounts

let accounts = try monzo.accounts(accessToken: "a_token")

Balance

let balance = try monzo.balance(accessToken: "a_token", accountId: "an_account_id")

Transactions

// list all transactions
let transactions = try monzo.transactions(accessToken: "a_token", accountId: "an_account_id")

// list transactions, filtered and paginated
let transactions = try monzo.transactions(accessToken: "a_token", accountId: "an_account_id", since: .transaction("txid1234"), before: referenceDate, limit: 20)

// get transaction details
let transactionDetails = try monzo.transaction(accessToken: "a_token", id: "txid1234")

Annotate transaction

try monzo.annotate(transaction: "txid1234", with metadata: ["key1": "value1", "key2": "value2"], accessToken: String)

Feed

// create simple feed item
try monzo.createFeedItem(accessToken: "a_token", accountId: "an_account", title: "Hello!", imageUrl: "http://images.domain/1")

// create fully customized feed item
try.createFeedItem(
	accessToken: "a_token",
	accountId: "an_account_id",
	title: "happy days! πŸ•ΊπŸ½",
	imageUrl: "http://images.domain/an-image.jpeg?param=j&other=k",
	url: "http://my.website/?param1=1&param2=2",
	body: "this is a sample body",
	backgroundColor: "#FFFFFF",
	bodyColor: "#AAAAAA",
	titleColor: "#BBBBBB"
)

Webhooks

// create
let webhook =try monzo.createWebhook(accessToken: "a_token", accountId: "account_id", url: "http://host.domain/path")

// list
let webhooks = try monzo.webhooks(accessToken: "a_token", accountId: "account_id")

// delete
try monzo.deleteWebhook(accessToken: "a_token", id: "account_id")

Support

You can create a Github issue in this repository. When stating your issue be sure to add enough details about what's causing the problem and reproduction steps.

Also, you can get in touch with me on Twitter.

License

This project is released under the MIT license. See LICENSE for details.

monzo-swift's People

Contributors

marius-serban avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

monzo-swift's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.