Skip to content
Elixir SDK for Splitwise
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
test
.formatter.exs
.gitignore
.travis.yml
LICENSE
README.md
mix.exs
mix.lock

README.md

Build Status Coverage Status

Splitwise API wrapper

A wrapper for the Splitwise API.

Installation

The package can be installed by adding ex_splitwise to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_splitwise, "~> 0.1.0"}
  ]
end

Getting started

  1. Register your application to get a key and secret in order to authenticate to the API.
  2. Use the key and secret to get a token:

Let the user navigate to the authorize_url to enter their credentials:

  authorize_url = ExSplitwise.OAuth2.Client.authorize_url!()

Get a token with the code returned by Splitwise:

  def callback(conn, params) do
    ExSplitwise.OAuth2.Client.get_token!(params["code"])

    render(conn, "index.html")
  end
  1. Make a request (current_user)
def user(conn, _params) do
  %{body: body} = ExSplitwise.Users.current()

  json(conn, user)
end

Usage

All the functions return a %ExSplitwise.Reponse{} struct with the following fields:

  • body: decoded JSON
  • headers: list of headers returned by the server
  • status: HTTP status code

Functions

Users

  • current
    %{body: body} = ExSplitwise.Users.current()
  • get
    %{body: body} = ExSplitwise.Users.get(id)
  • update
    %{body: body} = ExSplitwise.Users.update(id, data)

Groups

  • all
    %{body: body} = ExSplitwise.Groups.all()
  • get
    %{body: body} = ExSplitwise.Groups.get(id)

Friends

  • all
    %{body: body} = ExSplitwise.Friends.all()
  • get
    %{body: body} = ExSplitwise.Friends.get(id)

Expenses

  • all
    %{body: body} = ExSplitwise.Expenses.all()
  • get
    %{body: body} = ExSplitwise.Expenses.get(id)
  • create
    %{body: body} = ExSplitwise.Expenses.create(data)
  • update
    %{body: body} = ExSplitwise.Expenses.update(id)
  • delete
    %{body: body} = Splitwise.Expenses.delete(id)

Notifications

  • all
    %{body: body} = ExSplitwise.Notifications.all()

Comments

  • get
    %{body: body} = ExSplitwise.Comments.get(id)

Currencies

  • all
    %{body: body} = ExSplitwise.Currencies.all()

Documentation can be found at https://hexdocs.pm/ex_splitwise.

Licensed under the MIT license.

You can’t perform that action at this time.