diff --git a/README.md b/README.md
index 95ef55d..6b26576 100644
--- a/README.md
+++ b/README.md
@@ -67,7 +67,11 @@ end
You can find more documentation at http://rubydoc.info/github/figo-connect/ruby-figo/master/frames
+Demos
+-----
+In this repository you can also have a look at a simple console(`console_demo.rb`) and web demo(`web_demo`). While the console demo simply accesses the figo API, the web demo implements the full OAuth flow.
+
Requirements
-============
+------------
This gem requires Ruby 1.9.
diff --git a/console_demo.rb b/console_demo.rb
new file mode 100644
index 0000000..286629e
--- /dev/null
+++ b/console_demo.rb
@@ -0,0 +1,14 @@
+require_relative "lib/figo"
+
+session = Figo::Session.new("ASHWLIkouP2O6_bgA2wWReRhletgWKHYjLqDaqb0LFfamim9RjexTo22ujRIP_cjLiRiSyQXyt2kM1eXU2XLFZQ0Hro15HikJQT_eNeT_9XQ")
+
+# Print out list of account numbers and balances.
+session.accounts.each do |account|
+ puts account.account_number
+ puts account.balance.balance
+end
+
+# Print out the list of all transaction originators/recipients of a specific account.
+session.get_account("A1.1").transactions.each do |transaction|
+ puts transaction.name
+end
diff --git a/web_demo/app.rb b/web_demo/app.rb
new file mode 100644
index 0000000..1a34a7a
--- /dev/null
+++ b/web_demo/app.rb
@@ -0,0 +1,56 @@
+require 'rubygems'
+require 'sinatra'
+require_relative '../lib/figo'
+
+CLIENT_ID = "CaESKmC8MAhNpDe5rvmWnSkRE_7pkkVIIgMwclgzGcQY"
+CLIENT_SECRET = "STdzfv0GXtEj_bwYn7AgCVszN1kKq5BdgEIKOM_fzybQ"
+connection = Figo::Connection.new(CLIENT_ID, CLIENT_SECRET, "http://localhost:3000/callback")
+
+configure do
+ enable :sessions
+ set :port, 3000
+end
+
+get '/callback*' do
+ if params['state'] != "qweqwe"
+ logger.info "qwe"
+ raise Exception.new("Bogus redirect, wrong state")
+ end
+
+ token_hash = connection.obtain_access_token(params['code'])
+ request.session['figo_token'] = token_hash['access_token']
+
+ redirect to('/')
+end
+
+get '/logout' do
+ request.session['figo_token'] = nil
+ redirect to('/')
+end
+
+before '/' do
+ logger.info request.path_info
+ unless session[:figo_token] or request.path_info == "/callback" then
+ redirect to(connection.login_url("qweqwe", "accounts=ro transactions=ro balance=ro user=ro"))
+ end
+end
+
+get '/:account_id' do | account_id |
+ session = Figo::Session.new(request.session['figo_token'])
+ @accounts = session.accounts
+ @current_account = session.get_account(account_id)
+ @transactions = @current_account.transactions
+ @user = session.user
+
+ erb :index
+end
+
+get '/' do
+ session = Figo::Session.new(request.session['figo_token'])
+ @accounts = session.accounts
+ @current_account = nil
+ @transactions = session.transactions
+ @user = session.user
+
+ erb :index
+end
diff --git a/web_demo/public/banking.css b/web_demo/public/banking.css
new file mode 100644
index 0000000..5e3ea3a
--- /dev/null
+++ b/web_demo/public/banking.css
@@ -0,0 +1 @@
+body { padding-top: 70px; }
diff --git a/web_demo/public/favicon.ico b/web_demo/public/favicon.ico
new file mode 100644
index 0000000..a9d58c7
Binary files /dev/null and b/web_demo/public/favicon.ico differ
diff --git a/web_demo/views/index.erb b/web_demo/views/index.erb
new file mode 100644
index 0000000..9c43d77
--- /dev/null
+++ b/web_demo/views/index.erb
@@ -0,0 +1,41 @@
+
+
<%= @current_account.nil? ? "Unified Inbox" : @current_account.name %>
+
+ <% if @current_account %>
+
+
Account Details
+
+
+ - Owner: <%= @current_account.owner %>
+ - Account Number: <%= @current_account.account_number %>
+ - Bank Code: <%= @current_account.bank_code %>
+ - IBAN: <%= @current_account.iban %>
+ - Balance: <%= @current_account.balance.balance %> <%= @current_account.currency %>
+
+
+
+ <% end %>
+
+
+
+ Date |
+ Name |
+ Account Number |
+ Purpose |
+ Amount |
+
+
+ <% if @transactions %>
+ <% @transactions.each do |transaction| %>
+
+ <%= transaction.value_date %> |
+ <%= transaction.name %> |
+ <%= transaction.account_number %> |
+ <%= transaction.purpose %> |
+ <%= transaction.amount %> |
+
+ <% end %>
+ <% end %>
+
+
+
diff --git a/web_demo/views/layout.erb b/web_demo/views/layout.erb
new file mode 100644
index 0000000..0bd3000
--- /dev/null
+++ b/web_demo/views/layout.erb
@@ -0,0 +1,53 @@
+
+
+
+ figo web banking
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <%if @error then %>
+
<%=@error%>
+ <% end %>
+ <%= yield %>
+
+
+
+
+
+
+
+
+
+
+