fidor_api 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +84 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/fidor_api.gemspec +32 -0
- data/lib/fidor_api/account.rb +46 -0
- data/lib/fidor_api/auth.rb +45 -0
- data/lib/fidor_api/client.rb +17 -0
- data/lib/fidor_api/collection.rb +55 -0
- data/lib/fidor_api/customer.rb +54 -0
- data/lib/fidor_api/errors.rb +8 -0
- data/lib/fidor_api/preauth.rb +39 -0
- data/lib/fidor_api/preauth_details.rb +97 -0
- data/lib/fidor_api/resource.rb +45 -0
- data/lib/fidor_api/token.rb +27 -0
- data/lib/fidor_api/transaction.rb +43 -0
- data/lib/fidor_api/transaction_details.rb +119 -0
- data/lib/fidor_api/transfer.rb +125 -0
- data/lib/fidor_api/user.rb +23 -0
- data/lib/fidor_api/version.rb +3 -0
- data/lib/fidor_api.rb +38 -0
- metadata +226 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 35bab1256f83d253acc2cadc504cb76446365ae5
         | 
| 4 | 
            +
              data.tar.gz: 045a5090ae3dbbb4397795479782c5a3117a6795
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: d8db1a19cf9c1f401f157d4549cbc6abb865e470b6067e12388d83f5afcabcad23b73aaaa7a327e1fc169b09ed779fb2b60ee687432826e0d65d9e66b1e22b5f
         | 
| 7 | 
            +
              data.tar.gz: 8a44e7020efbb525d8a07838cdf0a543fde15e6ffbbc883db9346c44c061176636479536fffdceeeb1be5f6ffecbb4ce6f6000c4c5e4817dcfd2c092eb0e6a6c
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.ruby-gemset
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            fidor-api-gem
         | 
    
        data/.ruby-version
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            2.2.3
         | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            The MIT License (MIT)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Copyright (c) 2015 Klaus Meyer
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         | 
| 6 | 
            +
            of this software and associated documentation files (the "Software"), to deal
         | 
| 7 | 
            +
            in the Software without restriction, including without limitation the rights
         | 
| 8 | 
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 9 | 
            +
            copies of the Software, and to permit persons to whom the Software is
         | 
| 10 | 
            +
            furnished to do so, subject to the following conditions:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            The above copyright notice and this permission notice shall be included in
         | 
| 13 | 
            +
            all copies or substantial portions of the Software.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 16 | 
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 17 | 
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         | 
| 18 | 
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 19 | 
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         | 
| 20 | 
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         | 
| 21 | 
            +
            THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,84 @@ | |
| 1 | 
            +
            # FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            [](https://travis-ci.org/klausmeyer/fidor_api)
         | 
| 4 | 
            +
            [](https://codeclimate.com/github/klausmeyer/fidor_api/coverage)
         | 
| 5 | 
            +
            [](https://codeclimate.com/github/klausmeyer/fidor_api)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Simple ruby client for the Fidor Bank REST-API: http://docs.fidor.de
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ## Installation
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            Add this line to your application's Gemfile:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ```ruby
         | 
| 14 | 
            +
            gem 'fidor_api'
         | 
| 15 | 
            +
            ```
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            And then execute:
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                $ bundle
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            Or install it yourself as:
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                $ gem install fidor_api
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            ## Usage
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            Examples:
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            1. oAuth
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            ```ruby
         | 
| 32 | 
            +
            todo
         | 
| 33 | 
            +
            ```
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            2. Fetching data
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            ```ruby
         | 
| 38 | 
            +
            token = FidorApi::Token.new(access_token: "f859032a6ca0a4abb2be0583b8347937")
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            client = FidorApi::Client.new(token: token)
         | 
| 41 | 
            +
            user = client.current_user
         | 
| 42 | 
            +
            # => FidorApi::User
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            transactions = client.transactions
         | 
| 45 | 
            +
            # => FidorApi::Collection
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            transaction = transactions.first
         | 
| 48 | 
            +
            # => FidorApi::Transaction
         | 
| 49 | 
            +
            ```
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            3. Creating transfers
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            ```ruby
         | 
| 54 | 
            +
            token = FidorApi::Token.new(access_token: "f859032a6ca0a4abb2be0583b8347937")
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            client = FidorApi::Client.new(token: token)
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            transfer = client.build_internal_transfer(
         | 
| 59 | 
            +
              account_id:   875,
         | 
| 60 | 
            +
              receiver:     "kycfull@fidor.de",
         | 
| 61 | 
            +
              external_uid: "4279762F5",
         | 
| 62 | 
            +
              subject:      "Money for you",
         | 
| 63 | 
            +
              amount:       1000
         | 
| 64 | 
            +
            )
         | 
| 65 | 
            +
            # => FidorApi::Transfer::Internal
         | 
| 66 | 
            +
             | 
| 67 | 
            +
            transfer.save
         | 
| 68 | 
            +
            # => true / or raise error
         | 
| 69 | 
            +
            ```
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            ## Development
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         | 
| 74 | 
            +
             | 
| 75 | 
            +
            To install this gem onto your local machine, run `bundle exec rake install`.
         | 
| 76 | 
            +
             | 
| 77 | 
            +
            ## Contributing
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/klausmeyer/fidor_api.
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            ## License
         | 
| 82 | 
            +
             | 
| 83 | 
            +
            The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
         | 
| 84 | 
            +
             | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/console
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "bundler/setup"
         | 
| 4 | 
            +
            require "fidor_api"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # You can add fixtures and/or initialization code here to make experimenting
         | 
| 7 | 
            +
            # with your gem easier. You can also use a different console, if you like.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # (If you use this, don't forget to add pry to your Gemfile!)
         | 
| 10 | 
            +
            # require "pry"
         | 
| 11 | 
            +
            # Pry.start
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            require "irb"
         | 
| 14 | 
            +
            IRB.start
         | 
    
        data/bin/setup
    ADDED
    
    
    
        data/fidor_api.gemspec
    ADDED
    
    | @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'fidor_api/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "fidor_api"
         | 
| 8 | 
            +
              spec.version       = FidorApi::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["Klaus Meyer"]
         | 
| 10 | 
            +
              spec.email         = ["spam@klaus-meyer.net"]
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              spec.summary       = "Simple ruby client for the Fidor Bank API"
         | 
| 13 | 
            +
              spec.description   = "Connect to the Fidor Bank API"
         | 
| 14 | 
            +
              spec.homepage      = "https://github.com/klausmeyer/fidor_api"
         | 
| 15 | 
            +
              spec.license       = "MIT"
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         | 
| 18 | 
            +
              spec.require_paths = ["lib"]
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              spec.add_dependency "faraday", "~> 0.8"
         | 
| 21 | 
            +
              spec.add_dependency "activesupport", "~> 4.2"
         | 
| 22 | 
            +
              spec.add_dependency "activemodel", "~> 4.2"
         | 
| 23 | 
            +
              spec.add_dependency "model_attribute", "~> 2.1"
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              spec.add_development_dependency "bundler", "~> 1.10"
         | 
| 26 | 
            +
              spec.add_development_dependency "byebug", "~> 8.2"
         | 
| 27 | 
            +
              spec.add_development_dependency "rake", "~> 10.0"
         | 
| 28 | 
            +
              spec.add_development_dependency "rspec", "~> 3.3"
         | 
| 29 | 
            +
              spec.add_development_dependency "shoulda-matchers", "~> 2.8"
         | 
| 30 | 
            +
              spec.add_development_dependency "vcr", "~> 2.9"
         | 
| 31 | 
            +
              spec.add_development_dependency "simplecov", "~> 0.10"
         | 
| 32 | 
            +
            end
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Account < Resource
         | 
| 4 | 
            +
                extend ModelAttribute
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                attribute :id,                    :integer
         | 
| 7 | 
            +
                attribute :account_number,        :string
         | 
| 8 | 
            +
                attribute :iban,                  :string
         | 
| 9 | 
            +
                attribute :bic,                   :string
         | 
| 10 | 
            +
                attribute :balance,               :integer
         | 
| 11 | 
            +
                attribute :balance_available,     :integer
         | 
| 12 | 
            +
                attribute :preauth_amount,        :integer
         | 
| 13 | 
            +
                attribute :cash_flow_per_year,    :integer
         | 
| 14 | 
            +
                attribute :is_debit_note_enabled, :boolean
         | 
| 15 | 
            +
                attribute :is_trusted,            :boolean
         | 
| 16 | 
            +
                attribute :is_locked,             :boolean
         | 
| 17 | 
            +
                attribute :currency,              :string
         | 
| 18 | 
            +
                attribute :overdraft,             :integer
         | 
| 19 | 
            +
                attribute :created_at,            :time
         | 
| 20 | 
            +
                attribute :updated_at,            :time
         | 
| 21 | 
            +
                attribute :customers,             :string
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def self.all(access_token, options = {})
         | 
| 24 | 
            +
                  Collection.build(self, request(:get, access_token, "/accounts", options))
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def self.first(access_token)
         | 
| 28 | 
            +
                  all(access_token, page: 1, per_page: 1).first
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                def customers=(array)
         | 
| 32 | 
            +
                  @customers = array.map { |customer| Customer.new(customer) }
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                module ClientSupport
         | 
| 36 | 
            +
                  def accounts(options = {})
         | 
| 37 | 
            +
                    Account.all(token.access_token, options)
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  def first_account
         | 
| 41 | 
            +
                    Account.first(token.access_token)
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            end
         | 
| @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              module Auth
         | 
| 4 | 
            +
                extend self
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                def authorize_url
         | 
| 7 | 
            +
                  fidor_authorize_url
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                def fetch_token(code)
         | 
| 11 | 
            +
                  response = connection.post "/oauth/token", {
         | 
| 12 | 
            +
                    client_id:    FidorApi.configuration.client_id,
         | 
| 13 | 
            +
                    redirect_uri: FidorApi.configuration.callback_url,
         | 
| 14 | 
            +
                    code:         code,
         | 
| 15 | 
            +
                    grant_type:   "authorization_code"
         | 
| 16 | 
            +
                  }
         | 
| 17 | 
            +
                  Token.new JSON.parse(response.body)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                def refresh_token(token)
         | 
| 21 | 
            +
                  response = connection.post "/oauth/token", {
         | 
| 22 | 
            +
                    grant_type:    "refresh_token",
         | 
| 23 | 
            +
                    refresh_token: token.refresh_token
         | 
| 24 | 
            +
                  }
         | 
| 25 | 
            +
                  Token.new JSON.parse(response.body)
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                private
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                def connection
         | 
| 31 | 
            +
                  Faraday.new(url: FidorApi.configuration.oauth_url) do |config|
         | 
| 32 | 
            +
                    config.use      Faraday::Request::BasicAuthentication, FidorApi.configuration.client_id, FidorApi.configuration.client_secret
         | 
| 33 | 
            +
                    config.request  :url_encoded
         | 
| 34 | 
            +
                    config.response :logger       if FidorApi.configuration.logging
         | 
| 35 | 
            +
                    config.response :raise_error
         | 
| 36 | 
            +
                    config.adapter  Faraday.default_adapter
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                def fidor_authorize_url(state = "empty")
         | 
| 41 | 
            +
                  "#{FidorApi.configuration.oauth_url}/oauth/authorize?client_id=#{FidorApi.configuration.client_id}&redirect_uri=#{CGI::escape FidorApi.configuration.callback_url}&state=#{state}&response_type=code"
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            end
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Client
         | 
| 4 | 
            +
                include ActiveModel::Model
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                attr_accessor :token
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                include Account::ClientSupport
         | 
| 9 | 
            +
                include Customer::ClientSupport
         | 
| 10 | 
            +
                include Preauth::ClientSupport
         | 
| 11 | 
            +
                include Transaction::ClientSupport
         | 
| 12 | 
            +
                include Transfer::Internal::ClientSupport
         | 
| 13 | 
            +
                include Transfer::SEPA::ClientSupport
         | 
| 14 | 
            +
                include User::ClientSupport
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            end
         | 
| @@ -0,0 +1,55 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Collection
         | 
| 4 | 
            +
                include ActiveModel::Model
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                attr_accessor :records
         | 
| 7 | 
            +
                attr_accessor :total_pages, :current_page, :limit_value
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                delegate :each, :first, to: :records
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                def self.build(klass, response)
         | 
| 12 | 
            +
                  new.tap do |object|
         | 
| 13 | 
            +
                    # NOTE: We need this ugly hack since the sandbox is not wrapping records into data key.
         | 
| 14 | 
            +
                    # Will hopefully go away in future.
         | 
| 15 | 
            +
                    if response.is_a? Hash
         | 
| 16 | 
            +
                      data       = response["data"]
         | 
| 17 | 
            +
                      collection = response["collection"]
         | 
| 18 | 
            +
                    else
         | 
| 19 | 
            +
                      data       = response
         | 
| 20 | 
            +
                      collection = collection_from_array response
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                    object.records      = data.map { |record| klass.new(record) }
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    object.total_pages  = collection["total_pages"]
         | 
| 26 | 
            +
                    object.current_page = collection["current_page"]
         | 
| 27 | 
            +
                    object.limit_value  = collection["per_page"]
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                def to_a
         | 
| 32 | 
            +
                  records
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                # --- kaminari stuff -- maybe move somewhere else
         | 
| 36 | 
            +
                def last_page?
         | 
| 37 | 
            +
                  current_page == total_pages
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                def next_page
         | 
| 41 | 
            +
                  current_page + 1
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                private
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                def self.collection_from_array(array)
         | 
| 47 | 
            +
                  {
         | 
| 48 | 
            +
                    "total_pages"  => 1,
         | 
| 49 | 
            +
                    "current_page" => 1,
         | 
| 50 | 
            +
                    "per_page"     => array.count
         | 
| 51 | 
            +
                  }
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            end
         | 
| @@ -0,0 +1,54 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Customer < Resource
         | 
| 4 | 
            +
                extend ModelAttribute
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                attribute :id,                        :integer
         | 
| 7 | 
            +
                attribute :email,                     :string
         | 
| 8 | 
            +
                attribute :first_name,                :string
         | 
| 9 | 
            +
                attribute :last_name,                 :string
         | 
| 10 | 
            +
                attribute :gender,                    :string
         | 
| 11 | 
            +
                attribute :title,                     :string
         | 
| 12 | 
            +
                attribute :nick,                      :string
         | 
| 13 | 
            +
                attribute :maiden_name,               :string
         | 
| 14 | 
            +
                attribute :adr_street,                :string
         | 
| 15 | 
            +
                attribute :adr_street_number,         :string
         | 
| 16 | 
            +
                attribute :adr_post_code,             :string
         | 
| 17 | 
            +
                attribute :adr_city,                  :string
         | 
| 18 | 
            +
                attribute :adr_country,               :string
         | 
| 19 | 
            +
                attribute :adr_phone,                 :string
         | 
| 20 | 
            +
                attribute :adr_mobile,                :string
         | 
| 21 | 
            +
                attribute :adr_fax,                   :string
         | 
| 22 | 
            +
                attribute :adr_businessphone,         :string
         | 
| 23 | 
            +
                attribute :birthday,                  :time
         | 
| 24 | 
            +
                attribute :is_verified,               :boolean
         | 
| 25 | 
            +
                attribute :nationality,               :string
         | 
| 26 | 
            +
                attribute :marital_status,            :integer
         | 
| 27 | 
            +
                attribute :religion,                  :integer
         | 
| 28 | 
            +
                attribute :id_card_registration_city, :string
         | 
| 29 | 
            +
                attribute :id_card_number,            :string
         | 
| 30 | 
            +
                attribute :id_card_valid_until,       :time
         | 
| 31 | 
            +
                attribute :created_at,                :time
         | 
| 32 | 
            +
                attribute :updated_at,                :time
         | 
| 33 | 
            +
                attribute :creditor_identifier,       :string
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                def self.all(access_token, options = {})
         | 
| 36 | 
            +
                  Collection.build(self, request(:get, access_token, "/customers", options))
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def self.first(access_token)
         | 
| 40 | 
            +
                  all(access_token, page: 1, per_page: 1).first
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                module ClientSupport
         | 
| 44 | 
            +
                  def customers(options = {})
         | 
| 45 | 
            +
                    Customer.all(token.access_token, options)
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  def first_customer
         | 
| 49 | 
            +
                    Customer.first(token.access_token)
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            end
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Preauth < Resource
         | 
| 4 | 
            +
                extend ModelAttribute
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                attribute :id,                   :integer
         | 
| 7 | 
            +
                attribute :account_id,           :string
         | 
| 8 | 
            +
                attribute :preauth_type,         :string
         | 
| 9 | 
            +
                attribute :preauth_type_details, :json
         | 
| 10 | 
            +
                attribute :amount,               :integer
         | 
| 11 | 
            +
                attribute :expires_at,           :time
         | 
| 12 | 
            +
                attribute :created_at,           :time
         | 
| 13 | 
            +
                attribute :updated_at,           :time
         | 
| 14 | 
            +
                attribute :currency,             :string
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                def self.all(access_token, options = {})
         | 
| 17 | 
            +
                  Collection.build(self, request(:get, access_token, "/preauths", options))
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                def self.find(access_token, id)
         | 
| 21 | 
            +
                  new(request(:get, access_token, "/preauths/#{id}"))
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def preauth_type_details
         | 
| 25 | 
            +
                  @_preauth_type_details ||= PreauthDetails.build(@preauth_type, @preauth_type_details)
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                module ClientSupport
         | 
| 29 | 
            +
                  def preauths(options = {})
         | 
| 30 | 
            +
                    Preauth.all(token.access_token, options)
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  def preauth(id)
         | 
| 34 | 
            +
                    Preauth.find(token.access_token, id)
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            end
         | 
| @@ -0,0 +1,97 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              module PreauthDetails
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def self.build(type, hash)
         | 
| 6 | 
            +
                  implementation(type).new(hash)
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                class Base
         | 
| 10 | 
            +
                  def initialize(attributes = {})
         | 
| 11 | 
            +
                    set_attributes(attributes)
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def description
         | 
| 15 | 
            +
                    "-"
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                class CreditCard < Base
         | 
| 20 | 
            +
                  extend ModelAttribute
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  attribute :cc_category, :string
         | 
| 23 | 
            +
                  attribute :cc_merchant_category, :string
         | 
| 24 | 
            +
                  attribute :cc_merchant_name, :string
         | 
| 25 | 
            +
                  attribute :cc_sequence, :string
         | 
| 26 | 
            +
                  attribute :cc_type, :string
         | 
| 27 | 
            +
                  attribute :pos_code, :string
         | 
| 28 | 
            +
                  attribute :financial_network_code, :string
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def description
         | 
| 31 | 
            +
                    cc_merchant_name.presence || super
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                class InternalTransfer < Base
         | 
| 36 | 
            +
                  extend ModelAttribute
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  attribute :internal_transfer_id, :string
         | 
| 39 | 
            +
                  attribute :remote_account_id, :string
         | 
| 40 | 
            +
                  attribute :remote_bic, :string
         | 
| 41 | 
            +
                  attribute :remote_iban, :string
         | 
| 42 | 
            +
                  attribute :remote_name, :string
         | 
| 43 | 
            +
                  attribute :remote_nick, :string
         | 
| 44 | 
            +
                  attribute :remote_subject, :string
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  def description
         | 
| 47 | 
            +
                    remote_nick || remote_name || super
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                class CapitalBond < Base
         | 
| 52 | 
            +
                  extend ModelAttribute
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                class CurrencyOrder < Base
         | 
| 56 | 
            +
                  extend ModelAttribute
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                class Gmt < Base
         | 
| 60 | 
            +
                  extend ModelAttribute
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  attribute :destination_country, :string
         | 
| 63 | 
            +
                  attribute :destination_currency, :string
         | 
| 64 | 
            +
                  attribute :amount_in_destination_currency, :string
         | 
| 65 | 
            +
                  attribute :exchange_rate, :string
         | 
| 66 | 
            +
                  attribute :fee_transaction_id, :string
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                class Ripple < Base
         | 
| 70 | 
            +
                  extend ModelAttribute
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                class Unknown < Base
         | 
| 74 | 
            +
                  extend ModelAttribute
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                  def method_missing(method, *args)
         | 
| 77 | 
            +
                    return if method[-1] == "="
         | 
| 78 | 
            +
                    super
         | 
| 79 | 
            +
                  end
         | 
| 80 | 
            +
                end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                private
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                def self.implementation(type)
         | 
| 85 | 
            +
                  {
         | 
| 86 | 
            +
                    "creditcard_preauth"        => CreditCard,
         | 
| 87 | 
            +
                    "internal_transfer_preauth" => InternalTransfer,
         | 
| 88 | 
            +
                    "capital_bond_preauth"      => CapitalBond,
         | 
| 89 | 
            +
                    "currency_order_preauth"    => CurrencyOrder,
         | 
| 90 | 
            +
                    "gmt_preauth"               => Gmt,
         | 
| 91 | 
            +
                    "ripple_preauth"            => Ripple
         | 
| 92 | 
            +
                  }.fetch(type, Unknown)
         | 
| 93 | 
            +
                end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
              end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
            end
         | 
| @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Resource
         | 
| 4 | 
            +
                include ActiveModel::Model
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                attr_accessor :client
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                def initialize(attributes = {})
         | 
| 9 | 
            +
                  self.client = client
         | 
| 10 | 
            +
                  set_attributes(attributes)
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def self.request(method, access_token, endpoint, query_params = {}, body = {})
         | 
| 14 | 
            +
                  response = connection.public_send(method, endpoint) do |request|
         | 
| 15 | 
            +
                    request.params = query_params
         | 
| 16 | 
            +
                    request.headers = {
         | 
| 17 | 
            +
                      "Authorization" => "Bearer #{access_token}",
         | 
| 18 | 
            +
                      "Accept"        => "application/vnd.fidor.de; version=1,text/json",
         | 
| 19 | 
            +
                      "Content-Type"  => "application/json"
         | 
| 20 | 
            +
                    }
         | 
| 21 | 
            +
                    request.body = body.to_json unless body.empty?
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                  JSON.parse response.body
         | 
| 24 | 
            +
                rescue Faraday::Error::ClientError => e
         | 
| 25 | 
            +
                  if e.response[:status] == 401 && e.response[:body] =~ /token_not_found|Unauthorized token|expired/
         | 
| 26 | 
            +
                    raise UnauthorizedTokenError
         | 
| 27 | 
            +
                  else
         | 
| 28 | 
            +
                    raise ClientError
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                private
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def self.connection
         | 
| 35 | 
            +
                  Faraday.new(url: FidorApi.configuration.api_url) do |config|
         | 
| 36 | 
            +
                    config.use      Faraday::Request::BasicAuthentication, FidorApi.configuration.client_id, FidorApi.configuration.client_secret
         | 
| 37 | 
            +
                    config.request  :url_encoded
         | 
| 38 | 
            +
                    config.response :logger      if FidorApi.configuration.logging
         | 
| 39 | 
            +
                    config.response :raise_error
         | 
| 40 | 
            +
                    config.adapter  Faraday.default_adapter
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            end
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Token
         | 
| 4 | 
            +
                include ActiveModel::Model
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                attr_accessor :access_token, :expires_at, :token_type, :refresh_token, :state
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                def valid?
         | 
| 9 | 
            +
                  expires_at >= Time.now
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def expires_in=(value)
         | 
| 13 | 
            +
                  self.expires_at = Time.now + value.seconds
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                def to_hash
         | 
| 17 | 
            +
                  {
         | 
| 18 | 
            +
                    access_token:  access_token,
         | 
| 19 | 
            +
                    expires_at:    expires_at,
         | 
| 20 | 
            +
                    token_type:    token_type,
         | 
| 21 | 
            +
                    refresh_token: refresh_token,
         | 
| 22 | 
            +
                    state:         state
         | 
| 23 | 
            +
                  }
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            end
         | 
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Transaction < Resource
         | 
| 4 | 
            +
                extend ModelAttribute
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                attribute :id,                       :integer
         | 
| 7 | 
            +
                attribute :account_id,               :string
         | 
| 8 | 
            +
                attribute :transaction_type,         :string
         | 
| 9 | 
            +
                attribute :transaction_type_details, :json
         | 
| 10 | 
            +
                attribute :subject,                  :string
         | 
| 11 | 
            +
                attribute :amount,                   :integer
         | 
| 12 | 
            +
                attribute :currency,                 :string
         | 
| 13 | 
            +
                attribute :booking_date,             :time
         | 
| 14 | 
            +
                attribute :value_date,               :time
         | 
| 15 | 
            +
                attribute :booking_code,             :string
         | 
| 16 | 
            +
                attribute :return_transaction_id,    :string
         | 
| 17 | 
            +
                attribute :created_at,               :time
         | 
| 18 | 
            +
                attribute :updated_at,               :time
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                def self.all(access_token, options = {})
         | 
| 21 | 
            +
                  Collection.build(self, request(:get, access_token, "/transactions", options))
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def self.find(access_token, id)
         | 
| 25 | 
            +
                  new(request(:get, access_token, "/transactions/#{id}"))
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                def transaction_type_details
         | 
| 29 | 
            +
                  @_transaction_type_details ||= TransactionDetails.build(@transaction_type, @transaction_type_details)
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                module ClientSupport
         | 
| 33 | 
            +
                  def transactions(options = {})
         | 
| 34 | 
            +
                    Transaction.all(token.access_token, options)
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  def transaction(id)
         | 
| 38 | 
            +
                    Transaction.find(token.access_token, id)
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            end
         | 
| @@ -0,0 +1,119 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              module TransactionDetails
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def self.build(type, hash)
         | 
| 6 | 
            +
                  implementation(type).new(hash)
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                class Base
         | 
| 10 | 
            +
                  def initialize(attributes = {})
         | 
| 11 | 
            +
                    set_attributes(attributes)
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def remote_display_name
         | 
| 15 | 
            +
                    "Fidor Bank"
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                class Transfer < Base
         | 
| 20 | 
            +
                  extend ModelAttribute
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  attribute :internal_transfer_id, :string
         | 
| 23 | 
            +
                  attribute :sepa_credit_transfer_id, :string
         | 
| 24 | 
            +
                  attribute :remote_account_id, :string
         | 
| 25 | 
            +
                  attribute :remote_bic, :string
         | 
| 26 | 
            +
                  attribute :remote_iban, :string
         | 
| 27 | 
            +
                  attribute :remote_name, :string
         | 
| 28 | 
            +
                  attribute :remote_nick, :string
         | 
| 29 | 
            +
                  attribute :remote_subject, :string
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  def remote_display_name
         | 
| 32 | 
            +
                    remote_name.presence || remote_nick.presence || super
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                class CreditCard < Base
         | 
| 37 | 
            +
                  extend ModelAttribute
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  attribute :cc_category, :string
         | 
| 40 | 
            +
                  attribute :cc_merchant_category, :string
         | 
| 41 | 
            +
                  attribute :cc_merchant_name, :string
         | 
| 42 | 
            +
                  attribute :cc_sequence, :string
         | 
| 43 | 
            +
                  attribute :cc_type, :string
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  def remote_display_name
         | 
| 46 | 
            +
                    cc_merchant_name.presence || super
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                class Gmt < Base
         | 
| 51 | 
            +
                  extend ModelAttribute
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                  attribute :destination_country, :string
         | 
| 54 | 
            +
                  attribute :destination_currency, :string
         | 
| 55 | 
            +
                  attribute :amount_in_destination_currency, :string
         | 
| 56 | 
            +
                  attribute :exchange_rate, :string
         | 
| 57 | 
            +
                  attribute :fee_transaction_id, :string
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                class Bonus < Base
         | 
| 61 | 
            +
                  extend ModelAttribute
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                  attribute :affiliate_id, :string
         | 
| 64 | 
            +
                  attribute :affiliate_name, :string
         | 
| 65 | 
            +
                  attribute :affiliate_transaction_type_id, :string
         | 
| 66 | 
            +
                  attribute :affiliate_transaction_type_name, :string
         | 
| 67 | 
            +
                  attribute :affiliate_transaction_type_category, :string
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                class MobileTopup < Base
         | 
| 71 | 
            +
                  extend ModelAttribute
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                  attribute :provider, :string
         | 
| 74 | 
            +
                  attribute :phone_number, :string
         | 
| 75 | 
            +
                  attribute :topup_subject, :string
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                class Unknown < Base
         | 
| 79 | 
            +
                  extend ModelAttribute
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  def method_missing(method, *args)
         | 
| 82 | 
            +
                    return if method[-1] == "="
         | 
| 83 | 
            +
                    super
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
                end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                private
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                def self.implementation(type)
         | 
| 90 | 
            +
                  {
         | 
| 91 | 
            +
                    "fidor_payin"                     => Transfer,
         | 
| 92 | 
            +
                    "fidor_payout"                    => Transfer,
         | 
| 93 | 
            +
                    "emoney_payin"                    => Transfer,
         | 
| 94 | 
            +
                    "sepa_payin"                      => Transfer,
         | 
| 95 | 
            +
                    "payout"                          => Transfer,
         | 
| 96 | 
            +
                    "creditcard_preauth"              => CreditCard,
         | 
| 97 | 
            +
                    "creditcard_release"              => CreditCard,
         | 
| 98 | 
            +
                    "creditcard_payout"               => CreditCard,
         | 
| 99 | 
            +
                    "creditcard_payin"                => CreditCard,
         | 
| 100 | 
            +
                    "creditcard_annual_fee"           => CreditCard,
         | 
| 101 | 
            +
                    "creditcard_foreign_exchange_fee" => CreditCard,
         | 
| 102 | 
            +
                    "creditcard_order_fee"            => CreditCard,
         | 
| 103 | 
            +
                    "creditcard_order_cancellation"   => CreditCard,
         | 
| 104 | 
            +
                    "creditcard_order_withdrawal_fee" => CreditCard,
         | 
| 105 | 
            +
                    "creditcard_atm_fee"              => CreditCard,
         | 
| 106 | 
            +
                    "creditcard_notification_fee"     => CreditCard,
         | 
| 107 | 
            +
                    "sepa_core_direct_debit"          => Transfer,
         | 
| 108 | 
            +
                    "sepa_b2b_direct_debit"           => Transfer,
         | 
| 109 | 
            +
                    "gmt_payout"                      => Gmt,
         | 
| 110 | 
            +
                    "gmt_refund"                      => Gmt,
         | 
| 111 | 
            +
                    "gmt_fee"                         => Gmt,
         | 
| 112 | 
            +
                    "bonus"                           => Bonus,
         | 
| 113 | 
            +
                    "prepaid_mobile_topup"            => MobileTopup
         | 
| 114 | 
            +
                  }.fetch(type, Unknown)
         | 
| 115 | 
            +
                end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
             | 
| 119 | 
            +
            end
         | 
| @@ -0,0 +1,125 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              module Transfer
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                class Base < Resource
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  def save
         | 
| 8 | 
            +
                    raise InvalidRecordError unless valid?
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                    set_attributes self.class.request(:post, client.token.access_token, self.class.resource, {}, as_json)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                    true
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def self.all(access_token, options = {})
         | 
| 16 | 
            +
                    Collection.build(self, request(:get, access_token, resource, options))
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def self.find(access_token, id)
         | 
| 20 | 
            +
                    new(request(:get, access_token, "/#{resource}/#{id}"))
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                class Internal < Base
         | 
| 26 | 
            +
                  extend ModelAttribute
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  attribute :id,             :integer
         | 
| 29 | 
            +
                  attribute :account_id,     :string
         | 
| 30 | 
            +
                  attribute :user_id,        :string
         | 
| 31 | 
            +
                  attribute :transaction_id, :string
         | 
| 32 | 
            +
                  attribute :receiver,       :string
         | 
| 33 | 
            +
                  attribute :external_uid,   :string
         | 
| 34 | 
            +
                  attribute :amount,         :integer
         | 
| 35 | 
            +
                  attribute :currency,       :string
         | 
| 36 | 
            +
                  attribute :subject,        :string
         | 
| 37 | 
            +
                  attribute :state,          :string
         | 
| 38 | 
            +
                  attribute :created_at,     :time
         | 
| 39 | 
            +
                  attribute :updated_at,     :time
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  def self.required_attributes
         | 
| 42 | 
            +
                    [ :account_id, :receiver, :external_uid, :amount, :subject ]
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  validates *required_attributes, presence: true
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  private
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  def self.resource
         | 
| 50 | 
            +
                    "internal_transfers"
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                  def as_json
         | 
| 54 | 
            +
                    attributes.slice *self.class.required_attributes
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  module ClientSupport
         | 
| 58 | 
            +
                    def internal_transfers(options = {})
         | 
| 59 | 
            +
                      Transfer::Internal.all(token.access_token, options)
         | 
| 60 | 
            +
                    end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                    def internal_transfer(id)
         | 
| 63 | 
            +
                      Transfer::Internal.find(token.access_token, id)
         | 
| 64 | 
            +
                    end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                    def build_internal_transfer(attributes = {})
         | 
| 67 | 
            +
                      Transfer::Internal.new(attributes.merge(client: self))
         | 
| 68 | 
            +
                    end
         | 
| 69 | 
            +
                  end
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                class SEPA < Base
         | 
| 73 | 
            +
                  extend ModelAttribute
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                  attribute :id,             :integer
         | 
| 76 | 
            +
                  attribute :account_id,     :string
         | 
| 77 | 
            +
                  attribute :user_id,        :string
         | 
| 78 | 
            +
                  attribute :transaction_id, :string
         | 
| 79 | 
            +
                  attribute :remote_iban,    :string
         | 
| 80 | 
            +
                  attribute :remote_bic,     :string
         | 
| 81 | 
            +
                  attribute :remote_name,    :string
         | 
| 82 | 
            +
                  attribute :amount,         :integer
         | 
| 83 | 
            +
                  attribute :external_uid,   :string
         | 
| 84 | 
            +
                  attribute :subject,        :string
         | 
| 85 | 
            +
                  attribute :currency,       :string
         | 
| 86 | 
            +
                  attribute :subject,        :string
         | 
| 87 | 
            +
                  attribute :state,          :string
         | 
| 88 | 
            +
                  attribute :created_at,     :time
         | 
| 89 | 
            +
                  attribute :updated_at,     :time
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                  def self.required_attributes
         | 
| 92 | 
            +
                    [ :account_id, :external_uid, :remote_iban, :remote_bic, :remote_name, :amount, :subject ]
         | 
| 93 | 
            +
                  end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                  validates *required_attributes, presence: true
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                  private
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                  def self.resource
         | 
| 100 | 
            +
                    "sepa_credit_transfers"
         | 
| 101 | 
            +
                  end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                  def as_json
         | 
| 104 | 
            +
                    attributes.slice *self.class.required_attributes
         | 
| 105 | 
            +
                  end
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                  module ClientSupport
         | 
| 108 | 
            +
                    def sepa_transfers(options = {})
         | 
| 109 | 
            +
                      Transfer::SEPA.all(token.access_token, options)
         | 
| 110 | 
            +
                    end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                    def sepa_transfer(id)
         | 
| 113 | 
            +
                      Transfer::SEPA.find(token.access_token, id)
         | 
| 114 | 
            +
                    end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                    def build_sepa_transfer(attributes = {})
         | 
| 117 | 
            +
                      Transfer::SEPA.new(attributes.merge(client: self))
         | 
| 118 | 
            +
                    end
         | 
| 119 | 
            +
                  end
         | 
| 120 | 
            +
                end
         | 
| 121 | 
            +
             | 
| 122 | 
            +
              end
         | 
| 123 | 
            +
             | 
| 124 | 
            +
            end
         | 
| 125 | 
            +
             | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            module FidorApi
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class User < Resource
         | 
| 4 | 
            +
                extend ModelAttribute
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                attribute :id,              :integer
         | 
| 7 | 
            +
                attribute :email,           :string
         | 
| 8 | 
            +
                attribute :last_sign_in_at, :string
         | 
| 9 | 
            +
                attribute :created_at,      :time
         | 
| 10 | 
            +
                attribute :updated_at,      :time
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def self.current(access_token)
         | 
| 13 | 
            +
                  new(request(:get, access_token, "/users/current"))
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                module ClientSupport
         | 
| 17 | 
            +
                  def current_user
         | 
| 18 | 
            +
                    User.current(token.access_token)
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            end
         | 
    
        data/lib/fidor_api.rb
    ADDED
    
    | @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            require "faraday"
         | 
| 2 | 
            +
            require "active_support"
         | 
| 3 | 
            +
            require "active_support/core_ext"
         | 
| 4 | 
            +
            require "active_model"
         | 
| 5 | 
            +
            require "model_attribute"
         | 
| 6 | 
            +
            require "json"
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            module FidorApi
         | 
| 9 | 
            +
              extend self
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              attr_accessor :configuration
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              class Configuration
         | 
| 14 | 
            +
                attr_accessor :callback_url, :oauth_url, :api_url, :client_id, :client_secret, :logging
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              def configure
         | 
| 18 | 
            +
                self.configuration = Configuration.new
         | 
| 19 | 
            +
                self.configuration.logging = true
         | 
| 20 | 
            +
                yield configuration
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            require "fidor_api/version"
         | 
| 25 | 
            +
            require "fidor_api/errors"
         | 
| 26 | 
            +
            require "fidor_api/token"
         | 
| 27 | 
            +
            require "fidor_api/auth"
         | 
| 28 | 
            +
            require "fidor_api/resource"
         | 
| 29 | 
            +
            require "fidor_api/collection"
         | 
| 30 | 
            +
            require "fidor_api/user"
         | 
| 31 | 
            +
            require "fidor_api/account"
         | 
| 32 | 
            +
            require "fidor_api/customer"
         | 
| 33 | 
            +
            require "fidor_api/transaction_details"
         | 
| 34 | 
            +
            require "fidor_api/transaction"
         | 
| 35 | 
            +
            require "fidor_api/preauth_details"
         | 
| 36 | 
            +
            require "fidor_api/preauth"
         | 
| 37 | 
            +
            require "fidor_api/transfer"
         | 
| 38 | 
            +
            require "fidor_api/client"
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,226 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: fidor_api
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Klaus Meyer
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-11-17 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: faraday
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0.8'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0.8'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: activesupport
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '4.2'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '4.2'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: activemodel
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '4.2'
         | 
| 48 | 
            +
              type: :runtime
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '4.2'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: model_attribute
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '2.1'
         | 
| 62 | 
            +
              type: :runtime
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '2.1'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: bundler
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - "~>"
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '1.10'
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - "~>"
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '1.10'
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: byebug
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - "~>"
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: '8.2'
         | 
| 90 | 
            +
              type: :development
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - "~>"
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: '8.2'
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: rake
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - "~>"
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: '10.0'
         | 
| 104 | 
            +
              type: :development
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - "~>"
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '10.0'
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: rspec
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - "~>"
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '3.3'
         | 
| 118 | 
            +
              type: :development
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - "~>"
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '3.3'
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: shoulda-matchers
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - "~>"
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: '2.8'
         | 
| 132 | 
            +
              type: :development
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - "~>"
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: '2.8'
         | 
| 139 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 140 | 
            +
              name: vcr
         | 
| 141 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 | 
            +
                requirements:
         | 
| 143 | 
            +
                - - "~>"
         | 
| 144 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 145 | 
            +
                    version: '2.9'
         | 
| 146 | 
            +
              type: :development
         | 
| 147 | 
            +
              prerelease: false
         | 
| 148 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 149 | 
            +
                requirements:
         | 
| 150 | 
            +
                - - "~>"
         | 
| 151 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 152 | 
            +
                    version: '2.9'
         | 
| 153 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 154 | 
            +
              name: simplecov
         | 
| 155 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 | 
            +
                requirements:
         | 
| 157 | 
            +
                - - "~>"
         | 
| 158 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            +
                    version: '0.10'
         | 
| 160 | 
            +
              type: :development
         | 
| 161 | 
            +
              prerelease: false
         | 
| 162 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 | 
            +
                requirements:
         | 
| 164 | 
            +
                - - "~>"
         | 
| 165 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            +
                    version: '0.10'
         | 
| 167 | 
            +
            description: Connect to the Fidor Bank API
         | 
| 168 | 
            +
            email:
         | 
| 169 | 
            +
            - spam@klaus-meyer.net
         | 
| 170 | 
            +
            executables: []
         | 
| 171 | 
            +
            extensions: []
         | 
| 172 | 
            +
            extra_rdoc_files: []
         | 
| 173 | 
            +
            files:
         | 
| 174 | 
            +
            - ".gitignore"
         | 
| 175 | 
            +
            - ".rspec"
         | 
| 176 | 
            +
            - ".ruby-gemset"
         | 
| 177 | 
            +
            - ".ruby-version"
         | 
| 178 | 
            +
            - ".travis.yml"
         | 
| 179 | 
            +
            - Gemfile
         | 
| 180 | 
            +
            - LICENSE.txt
         | 
| 181 | 
            +
            - README.md
         | 
| 182 | 
            +
            - Rakefile
         | 
| 183 | 
            +
            - bin/console
         | 
| 184 | 
            +
            - bin/setup
         | 
| 185 | 
            +
            - fidor_api.gemspec
         | 
| 186 | 
            +
            - lib/fidor_api.rb
         | 
| 187 | 
            +
            - lib/fidor_api/account.rb
         | 
| 188 | 
            +
            - lib/fidor_api/auth.rb
         | 
| 189 | 
            +
            - lib/fidor_api/client.rb
         | 
| 190 | 
            +
            - lib/fidor_api/collection.rb
         | 
| 191 | 
            +
            - lib/fidor_api/customer.rb
         | 
| 192 | 
            +
            - lib/fidor_api/errors.rb
         | 
| 193 | 
            +
            - lib/fidor_api/preauth.rb
         | 
| 194 | 
            +
            - lib/fidor_api/preauth_details.rb
         | 
| 195 | 
            +
            - lib/fidor_api/resource.rb
         | 
| 196 | 
            +
            - lib/fidor_api/token.rb
         | 
| 197 | 
            +
            - lib/fidor_api/transaction.rb
         | 
| 198 | 
            +
            - lib/fidor_api/transaction_details.rb
         | 
| 199 | 
            +
            - lib/fidor_api/transfer.rb
         | 
| 200 | 
            +
            - lib/fidor_api/user.rb
         | 
| 201 | 
            +
            - lib/fidor_api/version.rb
         | 
| 202 | 
            +
            homepage: https://github.com/klausmeyer/fidor_api
         | 
| 203 | 
            +
            licenses:
         | 
| 204 | 
            +
            - MIT
         | 
| 205 | 
            +
            metadata: {}
         | 
| 206 | 
            +
            post_install_message: 
         | 
| 207 | 
            +
            rdoc_options: []
         | 
| 208 | 
            +
            require_paths:
         | 
| 209 | 
            +
            - lib
         | 
| 210 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 211 | 
            +
              requirements:
         | 
| 212 | 
            +
              - - ">="
         | 
| 213 | 
            +
                - !ruby/object:Gem::Version
         | 
| 214 | 
            +
                  version: '0'
         | 
| 215 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 216 | 
            +
              requirements:
         | 
| 217 | 
            +
              - - ">="
         | 
| 218 | 
            +
                - !ruby/object:Gem::Version
         | 
| 219 | 
            +
                  version: '0'
         | 
| 220 | 
            +
            requirements: []
         | 
| 221 | 
            +
            rubyforge_project: 
         | 
| 222 | 
            +
            rubygems_version: 2.4.8
         | 
| 223 | 
            +
            signing_key: 
         | 
| 224 | 
            +
            specification_version: 4
         | 
| 225 | 
            +
            summary: Simple ruby client for the Fidor Bank API
         | 
| 226 | 
            +
            test_files: []
         |