bankscrap 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebfe09ab93a020eff2ab36510dee31dd4bd3b50b
4
- data.tar.gz: 197c3f50a4465a30521b40a053acc63d8319200d
3
+ metadata.gz: 27417d295cb4b8c1f6c6d5e21a45ae62a5c49627
4
+ data.tar.gz: 630ec94eeb87fa8981f73b2cea65562e1356a39f
5
5
  SHA512:
6
- metadata.gz: aaf90b7decc33ef007be0fd0579e56fd2ffd7f3d4dbc61bc7423b9444c1209df1fa3ef3adef8b82e332f6a7948d742d62d7107aa913bc595423cffb30d6e0a9e
7
- data.tar.gz: 1ff9929c99f38501222bb1efb5b8165d5b7f1e265967f6bf5507b082db94924843d935836c21f6797eaf0f31f88de07210182d16d7c3c47f7aebfc16470befb4
6
+ metadata.gz: 61536463748cd80fa26ed4abe26558b86cdcc7f2f475e314a179578d7c439efbf1dfea0539c48f64c614ac4bff1d5191f54db390fd8d809ab5daad92bd6e28ab
7
+ data.tar.gz: 31c6dbcd704f6a5cae04367551c48b4796772f35362040d2bf20b0d346bac043bef5071f37d6fbce54840e789fa25eabb5b849c74c732ce246c761eaf9ea7d12
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Bankscrap
1
+ # 💸 Bankscrap 💸
2
2
 
3
3
  [![](http://188.166.39.57:3000/badge.svg)](http://188.166.39.57:3000)
4
4
 
@@ -8,7 +8,8 @@ Feel free to contribute and add your bank if it isn't supported.
8
8
 
9
9
  ## Supported banks
10
10
 
11
- * **BBVA**: [bankscrap-bbva](https://github.com/bankscrap/bankscrap-bbva)
11
+ * **BBVA** (personal accounts): [bankscrap-bbva](https://github.com/bankscrap/bankscrap-bbva)
12
+ * **BBVA Net Cash** (business accounts): [bankscrap-bbva-net-cash](https://github.com/bankscrap/bankscrap-bbva-net-cash)
12
13
  * **ING Direct**: [bankscrap-ing](https://github.com/bankscrap/bankscrap-ing)
13
14
  * **Banc Sabadell** (WIP): [bankscrap-banc-sabadell](https://github.com/bankscrap/bankscrap-banc-sabadell)
14
15
 
@@ -144,7 +145,7 @@ account.transactions
144
145
 
145
146
  ## Contributing
146
147
 
147
- 1. Fork it ( https://github.com/bank-scrap/bank_scrap/fork )
148
+ 1. Fork it ( https://github.com/bankscrap/bankscrap/fork )
148
149
  2. Create your feature branch (`git checkout -b my-new-feature`)
149
150
  3. Commit your changes (`git commit -am 'Add some feature'`)
150
151
  4. Push to the branch (`git push origin my-new-feature`)
@@ -0,0 +1,38 @@
1
+ module Bankscrap
2
+ class AdapterGenerator < Thor::Group
3
+ include Thor::Actions
4
+
5
+ argument :bank_name
6
+
7
+ def self.source_root
8
+ File.join(File.dirname(__FILE__), 'templates')
9
+ end
10
+
11
+ def generate
12
+ self.destination_root = File.expand_path('.', gem_name)
13
+ directory '.'
14
+
15
+ say ""
16
+ say "Great! Now you can start implementing your bank's adapter for Bankscrap.", :yellow
17
+ say ""
18
+ say "To get started take a look to:", :yellow
19
+ say "#{destination_root}/#{gem_name}.rb", :yellow
20
+ say ""
21
+ say "If you need help you can join our Slack chat room. Click the Slack badge on Github:", :yellow
22
+ say "https://github.com/bankscrap/bankscrap", :yellow
23
+ end
24
+
25
+ protected
26
+
27
+ def bank_name_dasherized
28
+ @bank_name_dasherized ||= bank_name.underscore.dasherize
29
+ end
30
+ def gem_name
31
+ @gem_name ||= 'bankscrap-' + bank_name_dasherized
32
+ end
33
+
34
+ def module_name
35
+ @module_name ||= bank_name
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bankscrap/<%= bank_name_dasherized %>/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = '<%= gem_name %>'
8
+ spec.version = Bankscrap::<%= module_name %>::VERSION
9
+ spec.authors = ['Your Name']
10
+ spec.email = ['your@email.com']
11
+ spec.summary = '<%= bank_name %> adapter for Bankscrap'
12
+ spec.homepage = ''
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_runtime_dependency 'bankscrap'
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ end
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in <%= gem_name %>.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,56 @@
1
+ # Bankscrap::<%= module_name %>
2
+
3
+ Bankscrap adapter for <%= bank_name %>
4
+
5
+ **TODO**: write a proper description for your adapter.
6
+
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem '<%= gem_name %>'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install <%= gem_name %>
23
+
24
+ ## Usage
25
+
26
+ ### From terminal
27
+ #### Bank account balance
28
+
29
+ $ bankscrap balance <%= module_name %> --user YOUR_USER --password YOUR_PASSWORD --extra=company_code:YOUR_COMPANY_CODE
30
+
31
+
32
+ #### Transactions
33
+
34
+ $ bankscrap transactions <%= module_name %> --user YOUR_USER --password YOUR_PASSWORD --extra=company_code:YOUR_COMPANY_CODE
35
+
36
+ ---
37
+
38
+ For more details on usage instructions please read [Bankscrap readme](https://github.com/bankscrap/bankscrap/#usage).
39
+
40
+ ### From Ruby code
41
+
42
+ **TODO**: check if your bank adapter needs more extra_args for the initializer.
43
+
44
+ ```ruby
45
+ require '<%= gem_name %>'
46
+ <%= bank_name.underscore %> = Bankscrap::<%= module_name %>::Bank.new(YOUR_USER, YOUR_PASSWORD, extra_args: {arg: EXTRA_ARG_1})
47
+ ```
48
+
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it ( https://github.com/bankscrap/<%= gem_name %>/fork )
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create a new Pull Request
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,2 @@
1
+ require_relative 'bankscrap/<%= bank_name_dasherized %>/bank'
2
+ require_relative 'bankscrap/<%= bank_name_dasherized %>/version'
@@ -0,0 +1,91 @@
1
+ require 'bankscrap'
2
+ require 'securerandom'
3
+
4
+ module Bankscrap
5
+ module <%= module_name %>
6
+ class Bank < ::Bankscrap::Bank
7
+
8
+ # Define the endpoints for the Bank API here
9
+ # BASE_ENDPOINT = 'https://api.mybank.com'.freeze
10
+ # LOGIN_ENDPOINT = '/login'.freeze
11
+ # ACCOUNTS_ENDPOINT = '/accounts'.freeze
12
+ # TRANSACTIONS_ENDPOINT = '/transactions'.freeze
13
+
14
+ def initialize(user, password, log: false, debug: false, extra_args: nil)
15
+ @user = user
16
+ @password = password
17
+ @log = log
18
+ @debug = debug
19
+ # @extra_arg1 = extra_args.with_indifferent_access['extra_arg1']
20
+
21
+ initialize_connection
22
+
23
+ # Optional Custom headers
24
+ # user_agent = SecureRandom.hex(32).upcase + ';Android;LGE;Nexus 5;1080x1776;Android;5.1.1;BMES;4.4;xxhd'
25
+ # add_headers(
26
+ # 'User-Agent' => user_agent
27
+ # )
28
+
29
+ login
30
+ super
31
+ end
32
+
33
+ # Fetch all the accounts for the given user
34
+ #
35
+ # Should returns an array of Bankscrap::Account objects
36
+ def fetch_accounts
37
+ # Example if the API expects a JSON POST request
38
+ # response = post(BASE_ENDPOINT + ACCOUNTS_ENDPOINT, fields: {}.to_json)
39
+ # json = JSON.parse(response)
40
+ # json['accounts'].map { |data| build_account(data) }
41
+ end
42
+
43
+ # Fetch transactions for the given account.
44
+ #
45
+ # Account should be a Bankscrap::Account object
46
+ # Should returns an array of Bankscrap::Account objects
47
+ def fetch_transactions_for(account, start_date: Date.today - 1.month, end_date: Date.today)
48
+ # Example if the API expects a JSON POST request
49
+ # response = post(BASE_ENDPOINT + TRANSACTIONS_ENDPOINT, fields: {}.to_json)
50
+ # json = JSON.parse(response)
51
+ # json['transactions'].map { |data| build_transaction(data) }
52
+ end
53
+
54
+ private
55
+
56
+ # First request to login
57
+ def login
58
+ # Example if the API expects a JSON POST request
59
+ # params = { user: @user, password: @password }
60
+ # post(BASE_ENDPOINT + LOGIN_ENDPOINT, fields: params.to_json)
61
+ end
62
+
63
+ # Build an Account object from API data
64
+ def build_account(data)
65
+ Account.new(
66
+ bank: self,
67
+ id: REPLACE_ME,
68
+ name: REPLACE_ME,
69
+ available_balance: REPLACE_ME,
70
+ balance: REPLACE_ME,
71
+ currency: REPLACE_ME,
72
+ iban: REPLACE_ME,
73
+ description: REPLACE_ME
74
+ )
75
+ end
76
+
77
+ # Build a transaction object from API data
78
+ def build_transaction(data, account)
79
+ Transaction.new(
80
+ account: account,
81
+ id: REPLACE_ME,
82
+ amount: REPLACE_ME,
83
+ description: REPLACE_ME,
84
+ effective_date: REPLACE_ME,
85
+ currency: REPLACE_ME, # Should be a Money object
86
+ balance: REPLACE_ME # Should be a Money object
87
+ )
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,5 @@
1
+ module Bankscrap
2
+ module <%= bank_name %>
3
+ VERSION = '1.0.0'.freeze
4
+ end
5
+ end
data/lib/bankscrap/cli.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  require 'thor'
2
2
  require 'active_support/core_ext/string'
3
+ Dir[File.expand_path("../../..", __FILE__) + "/generators/*.rb"].each do |generator|
4
+ require generator
5
+ end
6
+
3
7
 
4
8
  module Bankscrap
5
9
  class CLI < Thor
@@ -63,6 +67,10 @@ module Bankscrap
63
67
  end
64
68
  end
65
69
 
70
+
71
+ register(Bankscrap::AdapterGenerator, "generate_adapter", "generate_adapter MyBankName",
72
+ "generates a template for a new Bankscrap bank adapter")
73
+
66
74
  private
67
75
 
68
76
  def assign_shared_options
@@ -1,3 +1,3 @@
1
1
  module Bankscrap
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.0.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bankscrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Cuevas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-01 00:00:00.000000000 Z
12
+ date: 2016-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -140,6 +140,15 @@ extra_rdoc_files: []
140
140
  files:
141
141
  - README.md
142
142
  - bin/bankscrap
143
+ - generators/adapter_generator.rb
144
+ - generators/templates/%gem_name%.gemspec.tt
145
+ - generators/templates/Gemfile.tt
146
+ - generators/templates/LICENSE.txt
147
+ - generators/templates/README.md.tt
148
+ - generators/templates/Rakefile.tt
149
+ - generators/templates/lib/%gem_name%.rb.tt
150
+ - generators/templates/lib/bankscrap/%bank_name_dasherized%/bank.rb.tt
151
+ - generators/templates/lib/bankscrap/%bank_name_dasherized%/version.rb.tt
143
152
  - lib/.DS_Store
144
153
  - lib/bankscrap.rb
145
154
  - lib/bankscrap/account.rb