bankscrap-ibercaja 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rubocop.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +1 -0
- data/bankscrap-ibercaja.gemspec +26 -0
- data/lib/bankscrap-ibercaja.rb +2 -0
- data/lib/bankscrap/ibercaja/bank.rb +106 -0
- data/lib/bankscrap/ibercaja/version.rb +5 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7ad3ab6f9e4e48dbc2d5d71952a6d4cb63e7db3f
|
4
|
+
data.tar.gz: 17802793579c0fd5fb9e478697a9fa4493d81b84
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8848dfc87d268c96a992dd0296995b1c50089b3c1ecfb902dda7800d576bad119bb82de9262b61af299e2b21ebdb362b9ae48b27436c5c3c9ceb5ae2347bc2c3
|
7
|
+
data.tar.gz: b2106e4c6ba1a8d04109dcda1ee241bd6188732815cdbf16483050a83bffc6245f28884a09db38be355b08d2ed571eb8dd8a62dd64050be9b04d3a40616bab5c
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2017 Mark Villacampa
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Bankscrap::Ibercaja
|
2
|
+
|
3
|
+
Bankscrap adapter for the API behind Ibercaja's [mobile app](https://itunes.apple.com/es/app/ibercaja/id515972019?mt=8).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'bankscrap-ibercaja'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install bankscrap-ibercaja
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
For usage instructions please read [Bankscrap readme](https://github.com/bankscrap/bankscrap#usage).
|
24
|
+
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it ( https://github.com/markvillacampa/bankscrap-ibercaja/fork )
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bankscrap/ibercaja/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'bankscrap-ibercaja'
|
8
|
+
spec.version = Bankscrap::Ibercaja::VERSION
|
9
|
+
spec.authors = ['Mark']
|
10
|
+
spec.email = ['m@markvillacampa.com']
|
11
|
+
spec.summary = 'Ibercaja 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', '~> 2.0.0'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'byebug', '~> 8.2', '>= 8.2.5'
|
25
|
+
spec.add_development_dependency 'rubocop', '~> 0.39.0'
|
26
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'bankscrap'
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'digest'
|
5
|
+
|
6
|
+
module Bankscrap
|
7
|
+
module Ibercaja
|
8
|
+
class Bank < ::Bankscrap::Bank
|
9
|
+
BASE_ENDPOINT = 'https://ewm.ibercajadirecto.com/'.freeze
|
10
|
+
POST_AUTH_ENDPOINT = BASE_ENDPOINT + 'api/usuarios/iniciarsesion'
|
11
|
+
PRODUCTS_ENDPOINT = BASE_ENDPOINT + 'api/cuentas'
|
12
|
+
|
13
|
+
REQUIRED_CREDENTIALS = [:dni, :password]
|
14
|
+
|
15
|
+
def initialize(credentials = {})
|
16
|
+
super do
|
17
|
+
@password = @password.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def balances
|
22
|
+
log 'get_balances'
|
23
|
+
balances = {}
|
24
|
+
total_balance = 0
|
25
|
+
@accounts.each do |account|
|
26
|
+
balances[account.description] = account.balance
|
27
|
+
total_balance += account.balance
|
28
|
+
end
|
29
|
+
|
30
|
+
balances['TOTAL'] = total_balance
|
31
|
+
balances
|
32
|
+
end
|
33
|
+
|
34
|
+
def fetch_accounts
|
35
|
+
log 'fetch_accounts'
|
36
|
+
|
37
|
+
JSON.parse(get(PRODUCTS_ENDPOINT))['Productos'].map do |account|
|
38
|
+
build_account(account)
|
39
|
+
end.compact
|
40
|
+
end
|
41
|
+
|
42
|
+
def fetch_transactions_for(account, start_date: Date.today - 1.month, end_date: Date.today)
|
43
|
+
log "fetch_transactions for #{account.id}"
|
44
|
+
|
45
|
+
params = {
|
46
|
+
'request.cuenta' => account.id,
|
47
|
+
'request.fechaInicio' => start_date.strftime('%Y/%m/%d'),
|
48
|
+
'request.fechaFin' => end_date.strftime('%Y/%m/%d'),
|
49
|
+
}
|
50
|
+
request = get("#{PRODUCTS_ENDPOINT}/movimientos", params: params)
|
51
|
+
json = JSON.parse(request)
|
52
|
+
json['Movimientos'].map do |transaction|
|
53
|
+
build_transaction(transaction, account)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def login
|
60
|
+
add_headers(
|
61
|
+
'Content-Type' => 'application/json; charset=utf-8',
|
62
|
+
'AppID' => 'IbercajaAppV2Piloto',
|
63
|
+
'version' => '2.4.8',
|
64
|
+
'PlayBackMode' => 'Real',
|
65
|
+
'Entidad' =>'2085',
|
66
|
+
'Dispositivo' => 'IOSP',
|
67
|
+
'Idioma' => 'es',
|
68
|
+
'Canal' => 'MOV',
|
69
|
+
)
|
70
|
+
params = {"Usuario" => @dni, "Clave" => @password,"Tarjeta" => false}
|
71
|
+
json = JSON.parse(post(POST_AUTH_ENDPOINT, fields: params.to_json))
|
72
|
+
add_headers(
|
73
|
+
'Ticket' => json['Ticket'],
|
74
|
+
'Usuario' => @dni,
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Build an Account object from API data
|
79
|
+
def build_account(data)
|
80
|
+
Account.new(
|
81
|
+
bank: self,
|
82
|
+
id: data['Numero'],
|
83
|
+
name: data['Alias'],
|
84
|
+
balance: Money.new(data['Saldo'] || 0, 'EUR'),
|
85
|
+
available_balance: Money.new(data['Dispuesto'] || 0, 'EUR'),
|
86
|
+
description: data['Alias'],
|
87
|
+
iban: data['IBAN'],
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Build a transaction object from API data
|
92
|
+
def build_transaction(data, account)
|
93
|
+
amount = Money.new(data['Importe'] || 0, 'EUR')
|
94
|
+
Transaction.new(
|
95
|
+
account: account,
|
96
|
+
# There is no unique id in the json, so we MD5 the json to create one
|
97
|
+
id: Digest::MD5.hexdigest(data.to_json),
|
98
|
+
amount: amount,
|
99
|
+
effective_date: Date.parse(data['FechaValor']),
|
100
|
+
description: data['ConceptoMovimiento'] + ' ' + data['Registros'].join(' '),
|
101
|
+
balance: Money.new(data['saldo'] || 0, 'EUR'),
|
102
|
+
)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bankscrap-ibercaja
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bankscrap
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '8.2'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 8.2.5
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '8.2'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 8.2.5
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rubocop
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.39.0
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.39.0
|
89
|
+
description:
|
90
|
+
email:
|
91
|
+
- m@markvillacampa.com
|
92
|
+
executables: []
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- ".gitignore"
|
97
|
+
- ".rubocop.yml"
|
98
|
+
- Gemfile
|
99
|
+
- LICENSE.txt
|
100
|
+
- README.md
|
101
|
+
- Rakefile
|
102
|
+
- bankscrap-ibercaja.gemspec
|
103
|
+
- lib/bankscrap-ibercaja.rb
|
104
|
+
- lib/bankscrap/ibercaja/bank.rb
|
105
|
+
- lib/bankscrap/ibercaja/version.rb
|
106
|
+
homepage: ''
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.6.8
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Ibercaja adapter for Bankscrap
|
130
|
+
test_files: []
|