From 3bdfafef4655117059d16692717b2023383a8859 Mon Sep 17 00:00:00 2001 From: "M. Neumayr" Date: Fri, 27 Apr 2018 15:27:43 +0200 Subject: [PATCH] add Ruby on Rails Fidor API Demo Application (#13) --- CHANGELOG.md | 20 ++++---- LICENSE.txt | 2 +- fidor_starter_kits.gemspec | 7 +-- lib/fidor_starter_kits.rb | 6 +-- spec/fidor_starter_kits_spec.rb | 1 + spec/spec_helper.rb | 3 +- starter_kits/ruby_on_rails_api_demo/.env | 6 +++ .../ruby_on_rails_api_demo/.fidor_meta.json | 9 ++++ starter_kits/ruby_on_rails_api_demo/README.md | 11 +++++ starter_kits/ruby_on_rails_api_demo/app.json | 48 +++++++++++++++++++ 10 files changed, 96 insertions(+), 17 deletions(-) create mode 100644 starter_kits/ruby_on_rails_api_demo/.env create mode 100644 starter_kits/ruby_on_rails_api_demo/.fidor_meta.json create mode 100644 starter_kits/ruby_on_rails_api_demo/README.md create mode 100644 starter_kits/ruby_on_rails_api_demo/app.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b79758..ae47c97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,27 +1,31 @@ # Changelog Fidor Admin API Schema + See [commit messages](https://github.com/fidor/fidor_starter_kits/commits/) for details. -##2016-04 +## 2018-04 + +* add Ruby on Rails Fidor API Demo Application + +## 2016-04 * add PHP advanced example -##2016-01 +## 2016-01 * remove client_secret usage in params => moved to BasicAuth header -##2015-06 +## 2015-06 * fix usage of access_token in api URLs, now set in Authorization Header -##2015-01 +## 2015-01 -*fix proper TLS handling for node example +* fix proper TLS handling for node example -##2014-12 +## 2014-12 * make starter kits use all required oauth params: state, response_type, grant_type - -##2014-11 +## 2014-11 * init with plain oauth examples for php, ruby, nodejs, golang, java diff --git a/LICENSE.txt b/LICENSE.txt index 3790ea8..01e24de 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2014 Georg Leciejewski +Copyright (c) 2018 Fidor Solutions AG MIT License diff --git a/fidor_starter_kits.gemspec b/fidor_starter_kits.gemspec index 76f2a9f..007b4d5 100644 --- a/fidor_starter_kits.gemspec +++ b/fidor_starter_kits.gemspec @@ -6,8 +6,8 @@ require 'fidor_starter_kits/version' Gem::Specification.new do |spec| spec.name = "fidor_starter_kits" spec.version = FidorStarterKits::VERSION - spec.authors = ["Georg Leciejewski"] - spec.email = ["dev@fidor.de"] + spec.authors = ["Fidor Solutions AG"] + spec.email = ["connect@fidor.com"] spec.summary = %q{BETA - Starter Kits for building fidor apps.} spec.description = %q{Fidor application examples for different languages. They rely on the BETA Version of the API so things may change.} spec.homepage = "" @@ -19,7 +19,8 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_runtime_dependency "rubyzip" - spec.add_development_dependency "bundler", "~> 1.5" + spec.add_development_dependency "bundler", "~> 1.16" spec.add_development_dependency "rake" spec.add_development_dependency 'rspec' + spec.add_development_dependency 'byebug' end diff --git a/lib/fidor_starter_kits.rb b/lib/fidor_starter_kits.rb index 15ecfd6..a9f3fc3 100644 --- a/lib/fidor_starter_kits.rb +++ b/lib/fidor_starter_kits.rb @@ -6,7 +6,7 @@ module FidorStarterKits - STARTER_KITS = %w{ node_tx golang_transactions php_oauth_plain ruby_oauth_plain java_servlet php_advanced } + STARTER_KITS = %w{ ruby_on_rails_api_demo ruby_oauth_plain php_oauth_plain php_advanced golang_transactions java_servlet node_tx } class << self @@ -40,7 +40,7 @@ def build(opts) FileUtils.copy_entry example_src_path, tmp_src_dir # read example files and replace placeholder with id/secret - example_files = File.join(tmp_src_dir, "**", "[Ee]xample.*") + example_files = File.join(tmp_src_dir, "**", "{[Ee]xample.*,app.json,.env}") Dir.glob(example_files) do |example_file| content = File.read(example_file) @@ -53,7 +53,7 @@ def build(opts) # create zip file in tmp dir zip_file_path = File.join(tmp_src_dir, "#{app_name}.zip") Zip::File.open(zip_file_path, Zip::File::CREATE) do |zipfile| - Dir.glob(File.join(tmp_src_dir, '**', '**'), File::FNM_DOTMATCH).each do |file| + Dir.glob(File.join(tmp_src_dir, '**', '**'), File::FNM_DOTMATCH).each do |file| zipfile.add(file.sub("#{tmp_src_dir}/", ''), file) unless file.end_with? '.' end end diff --git a/spec/fidor_starter_kits_spec.rb b/spec/fidor_starter_kits_spec.rb index 05da08d..719aa3d 100644 --- a/spec/fidor_starter_kits_spec.rb +++ b/spec/fidor_starter_kits_spec.rb @@ -56,6 +56,7 @@ it 'loads the json meta data' do conf = FidorStarterKits.all + expect(conf["ruby_on_rails_api_demo"]["display_name"]).to eq("Ruby on Rails Fidor API Demo Application") expect(conf["golang_transactions"]["display_name"]).to eq("Go Transactions") expect(conf["node_tx"]["description"]).to eq("NodeJS app getting transactions and accounts. Handling oAuth login.") expect(conf["php_oauth_plain"]["app_name"]).to eq("php_oauth_plain") diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e49ac76..46d3ff7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,5 @@ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'rspec' +require 'byebug' require 'fidor_starter_kits' -RSpec.configure do |config| -end \ No newline at end of file diff --git a/starter_kits/ruby_on_rails_api_demo/.env b/starter_kits/ruby_on_rails_api_demo/.env new file mode 100644 index 0000000..3a51bb9 --- /dev/null +++ b/starter_kits/ruby_on_rails_api_demo/.env @@ -0,0 +1,6 @@ +FIDOR_API_CALLBACK=/auth/callback +FIDOR_API_CLIENT_ID= +FIDOR_API_CLIENT_SECRET= +FIDOR_API_LOGGING=true +FIDOR_API_URL= +FIDOR_OAUTH_URL= diff --git a/starter_kits/ruby_on_rails_api_demo/.fidor_meta.json b/starter_kits/ruby_on_rails_api_demo/.fidor_meta.json new file mode 100644 index 0000000..31bbee0 --- /dev/null +++ b/starter_kits/ruby_on_rails_api_demo/.fidor_meta.json @@ -0,0 +1,9 @@ +{ + "display_name" : "Ruby on Rails Fidor API Demo Application", + "description" : "Demo Application for the `fidor_api` gem", + "description-de" : "Demo Application for the `fidor_api` gem", + "app_name": "ruby_on_rails_api_demo", + "app_url": "http://localhost:4000", + "callback_urls": "http://localhost:4000/auth/callback", + "language" : "ruby" +} diff --git a/starter_kits/ruby_on_rails_api_demo/README.md b/starter_kits/ruby_on_rails_api_demo/README.md new file mode 100644 index 0000000..6737e90 --- /dev/null +++ b/starter_kits/ruby_on_rails_api_demo/README.md @@ -0,0 +1,11 @@ +# Fidor API Demo + +This [Rails](http://rubyonrails.org) application demonstrates the capabilities of Fidor Bank API powered by the [fidor_api](https://github.com/fidor/fidor_api) ruby library. + +## Production Setup & Deployment + +Please read the detailed setup instructions on https://github.com/fidor/fidor_api_demo + +### Heroku deployment + +Copy the generated `app.json` file to the fidor_api_demo directory, this will prefill all required environment variables. diff --git a/starter_kits/ruby_on_rails_api_demo/app.json b/starter_kits/ruby_on_rails_api_demo/app.json new file mode 100644 index 0000000..f24fb5f --- /dev/null +++ b/starter_kits/ruby_on_rails_api_demo/app.json @@ -0,0 +1,48 @@ +{ + "name": "Fidor API Demo", + "description": "This application demonstrates the capabilities of Fidor Bank API powered by the `fidor_api` ruby library.", + "repository": "https://github.com/fidor/fidor_api_demo", + "keywords": ["fidor", "api", "demo", "rails"], + "env": { + "FIDOR_API_CALLBACK": { + "description": "The customer is redirected back to this URL during the oAuth flow", + "value": "/auth/callback" + }, + "FIDOR_API_CLIENT_ID": { + "description": "The unique ID assigned to your application by fidor", + "value": "" + }, + "FIDOR_API_CLIENT_SECRET": { + "description": "The secret assigned to your application by fidor", + "value": "" + }, + "FIDOR_API_LOGGING": { + "description": "Whether the `fidor_api` gem should log all requests done against the Fidor API", + "value": "true" + }, + "FIDOR_API_URL": { + "description": "The API endpoint which the `fidor_api` gem should use for regular requests", + "value": "" + }, + "FIDOR_OAUTH_URL": { + "description": "The API endpoint which the `fidor_api` gem should use for oAuth requests", + "value": "" + }, + "RAILS_ENV": { + "description": "Runs the rails application in production mode", + "value": "production" + }, + "RAILS_LOG_TO_STDOUT": { + "description": "Tells rails to log to STDOUT instead of a local logfile", + "value": "true" + }, + "RAILS_SERVE_STATIC_FILES": { + "description": "Tells rails to service static files by the application server", + "value": "true" + }, + "SECRET_KEY_BASE": { + "description": "A secret key used for different encryptions and checksums in rails", + "generator": "secret" + } + } +}