bankscrap-openbank 2.0.0
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/Gemfile +4 -0
- data/LICENSE.txt +20 -0
- data/README.md +51 -0
- data/Rakefile +1 -0
- data/bankscrap-openbank.gemspec +24 -0
- data/lib/bankscrap-openbank.rb +2 -0
- data/lib/bankscrap/openbank/account.rb +79 -0
- data/lib/bankscrap/openbank/bank.rb +164 -0
- data/lib/bankscrap/openbank/card.rb +75 -0
- data/lib/bankscrap/openbank/utils.rb +17 -0
- data/lib/bankscrap/openbank/version.rb +5 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b1b65647a5159a87170071f62b9e436746cc82e0
|
4
|
+
data.tar.gz: f29fa5cf4c2ab71265e6c73beb806e71ce92ea0d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9e0d44b99398209c21b48c6c34ac64b6c6c2d9af3d3aaaa4ea5da443024f0bb5a5687493841b6d16a22c9738ef62ec4b2937efefa567b8f6cf94777759e0bbfd
|
7
|
+
data.tar.gz: 7deac7f651ea8e0445b4bcd390358755a0ea89ec4af3976a706ebde8c6b1a642e2baff4df3eae68b2b7e34192d2ba72fba10fc71ce2979a72eca4fa138961fe5
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -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.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Bankscrap::Openbank
|
2
|
+
|
3
|
+
[Bankscrap](https://github.com/bankscrap/bankscrap) adapter for Openbank.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'bankscrap-openbank'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install bankscrap-openbank
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### From terminal
|
24
|
+
#### Bank account balance
|
25
|
+
|
26
|
+
$ bankscrap balance Openbank --credentials=user:YOUR_USER --password:YOUR_PASSWORD
|
27
|
+
|
28
|
+
|
29
|
+
#### Transactions
|
30
|
+
|
31
|
+
$ bankscrap transactions Openbank --credentials=user:YOUR_USER --password:YOUR_PASSWORD
|
32
|
+
|
33
|
+
---
|
34
|
+
|
35
|
+
For more details on usage instructions please read [Bankscrap readme](https://github.com/bankscrap/bankscrap/#usage).
|
36
|
+
|
37
|
+
### From Ruby code
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
require 'bankscrap-openbank'
|
41
|
+
openbank = Bankscrap::Openbank::Bank.new(user: YOUR_USER, password: YOUR_PASSWORD)
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it ( https://github.com/bankscrap/bankscrap-openbank/fork )
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bankscrap/openbank/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'bankscrap-openbank'
|
8
|
+
spec.version = Bankscrap::Openbank::VERSION
|
9
|
+
spec.authors = ['zjuanma']
|
10
|
+
spec.email = ['zjuanma@gmail.com']
|
11
|
+
spec.summary = 'Openbank adapter for Bankscrap'
|
12
|
+
spec.homepage = 'https://github.com/zjuanma/bankscrap-openbank'
|
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
|
+
spec.add_development_dependency 'byebug', '~> 8.0'
|
24
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require_relative 'utils.rb'
|
2
|
+
|
3
|
+
module Bankscrap
|
4
|
+
module Openbank
|
5
|
+
class Account < ::Bankscrap::Account
|
6
|
+
include Utils
|
7
|
+
|
8
|
+
attr_accessor :contract_id
|
9
|
+
|
10
|
+
ACCOUNT_ENDPOINT = '/OPB_BAMOBI_WS_ENS/ws/BAMOBI_WS_Def_Listener'.freeze
|
11
|
+
|
12
|
+
# Fetch transactions for the given account.
|
13
|
+
# By default it fetches transactions for the last month,
|
14
|
+
#
|
15
|
+
# Returns an array of BankScrap::Transaction objects
|
16
|
+
def fetch_transactions_for(connection, start_date: Date.today - 1.month, end_date: Date.today)
|
17
|
+
transactions = []
|
18
|
+
end_page = false
|
19
|
+
repo = nil
|
20
|
+
importe_cta = nil
|
21
|
+
|
22
|
+
# Loop over pagination
|
23
|
+
until end_page
|
24
|
+
document = connection.post(ACCOUNT_ENDPOINT, fields: xml_account(connection, start_date, end_date, repo, importe_cta))
|
25
|
+
|
26
|
+
transactions += document.xpath('//listadoMovimientos/movimiento').map { |data| build_transaction(data) }
|
27
|
+
|
28
|
+
repo = document.at_xpath('//methodResult/repo')
|
29
|
+
importe_cta = document.at_xpath('//methodResult/importeCta')
|
30
|
+
end_page = value_at_xpath(document, '//methodResult/finLista') != 'N'
|
31
|
+
end
|
32
|
+
|
33
|
+
transactions
|
34
|
+
end
|
35
|
+
|
36
|
+
def xml_account(connection, from_date, to_date, repo, importe_cta)
|
37
|
+
is_pagination = repo ? 'S' : 'N'
|
38
|
+
xml_from_date = xml_date(from_date)
|
39
|
+
xml_to_date = xml_date(to_date)
|
40
|
+
<<-account
|
41
|
+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.isban.es/webservices/BAMOBI/Cuentas/F_bamobi_cuentas_lip/internet/BAMOBICTA/v1">
|
42
|
+
#{connection.xml_security_header}
|
43
|
+
<soapenv:Body>
|
44
|
+
<v1:listaMovCuentasFechas_LIP facade="BAMOBICTA">
|
45
|
+
<entrada>
|
46
|
+
#{connection.xml_datos_cabecera}
|
47
|
+
<datosConexion>#{connection.user_data.children}</datosConexion>
|
48
|
+
<contratoID>#{contract_id}</contratoID>
|
49
|
+
<fechaDesde>#{xml_from_date}</fechaDesde>
|
50
|
+
<fechaHasta>#{xml_to_date}</fechaHasta>
|
51
|
+
#{importe_cta}
|
52
|
+
<esUnaPaginacion>#{is_pagination}</esUnaPaginacion>
|
53
|
+
#{repo}
|
54
|
+
</entrada>
|
55
|
+
</v1:listaMovCuentasFechas_LIP>
|
56
|
+
</soapenv:Body>
|
57
|
+
</soapenv:Envelope>
|
58
|
+
account
|
59
|
+
end
|
60
|
+
|
61
|
+
def xml_date(date)
|
62
|
+
"<dia>#{date.day}</dia><mes>#{date.month}</mes><anyo>#{date.year}</anyo>"
|
63
|
+
end
|
64
|
+
|
65
|
+
# Build a transaction object from API data
|
66
|
+
def build_transaction(data)
|
67
|
+
Transaction.new(
|
68
|
+
account: self,
|
69
|
+
id: value_at_xpath(data, 'numeroMovimiento'),
|
70
|
+
amount: money(data, 'importe'),
|
71
|
+
description: value_at_xpath(data, 'descripcion'),
|
72
|
+
effective_date: Date.strptime(value_at_xpath(data, 'fechaValor'), '%Y-%m-%d'),
|
73
|
+
# TODO: Bankscrap has no interface to add operation date
|
74
|
+
balance: money(data, 'importeSaldo')
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'bankscrap'
|
2
|
+
require 'securerandom'
|
3
|
+
require 'byebug'
|
4
|
+
require_relative 'account.rb'
|
5
|
+
require_relative 'card.rb'
|
6
|
+
require_relative 'utils.rb'
|
7
|
+
|
8
|
+
module Bankscrap
|
9
|
+
module Openbank
|
10
|
+
class Bank < ::Bankscrap::Bank
|
11
|
+
include Utils
|
12
|
+
|
13
|
+
attr_accessor :user_data
|
14
|
+
|
15
|
+
# Define the endpoints for the Bank API here
|
16
|
+
BASE_ENDPOINT = 'https://www.openbank.mobi'.freeze
|
17
|
+
LOGIN_ENDPOINT = '/OPBMOV_IPAD_NSeg_ENS/ws/QUIZ_Def_Listener'.freeze
|
18
|
+
PRODUCTS_ENDPOINT = '/OPB_BAMOBI_WS_ENS/ws/BAMOBI_WS_Def_Listener'.freeze
|
19
|
+
USER_AGENT = 'Dalvik/1.6.0 (Linux; U; Android 4.4.4; XT1032 Build/KXB21.14-L1.40)'.freeze
|
20
|
+
|
21
|
+
def initialize(credentials = {})
|
22
|
+
super do
|
23
|
+
add_headers(
|
24
|
+
'Content-Type' => 'text/xml; charset=utf-8',
|
25
|
+
'User-Agent' => USER_AGENT,
|
26
|
+
'Host' => 'www.openbank.mobi',
|
27
|
+
'Connection' => 'Keep-Alive',
|
28
|
+
'Accept-Encoding' => 'gzip'
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def login
|
34
|
+
log 'login'
|
35
|
+
post(LOGIN_ENDPOINT, fields: xml_login(public_ip))
|
36
|
+
end
|
37
|
+
|
38
|
+
# Fetch all the accounts for the given user
|
39
|
+
#
|
40
|
+
# Should returns an array of Bankscrap::Account objects
|
41
|
+
def fetch_accounts
|
42
|
+
log 'fetch_accounts'
|
43
|
+
document = post(PRODUCTS_ENDPOINT, fields: xml_products)
|
44
|
+
document.xpath('//cuentas/cuenta').map { |data| build_account(data) } +
|
45
|
+
document.xpath('//tarjetas/tarjeta').map { |data| build_card(data) }
|
46
|
+
end
|
47
|
+
|
48
|
+
# Fetch transactions for the given account.
|
49
|
+
#
|
50
|
+
# Account should be a Bankscrap::Account object
|
51
|
+
# Should returns an array of Bankscrap::Account objects
|
52
|
+
def fetch_transactions_for(product, start_date: Date.today - 1.month, end_date: Date.today)
|
53
|
+
product.fetch_transactions_for(self, start_date: start_date, end_date: end_date)
|
54
|
+
end
|
55
|
+
|
56
|
+
def xml_security_header
|
57
|
+
<<-security
|
58
|
+
<soapenv:Header>
|
59
|
+
<wsse:Security SOAP-ENV:actor="http://www.isban.es/soap/actor/wssecurityB64" SOAP-ENV:mustUnderstand="1" S12:role="wsssecurity" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:S12="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
|
60
|
+
<wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SSOToken" ValueType="esquema" EncodingType="hwsse:Base64Binary">#{@token_credential}</wsse:BinarySecurityToken>
|
61
|
+
</wsse:Security>
|
62
|
+
</soapenv:Header>
|
63
|
+
security
|
64
|
+
end
|
65
|
+
|
66
|
+
def xml_datos_cabecera
|
67
|
+
<<-datos
|
68
|
+
<datosCabecera>
|
69
|
+
<version>3.0.4</version>
|
70
|
+
<terminalID>Android</terminalID>
|
71
|
+
<idioma>es-ES</idioma>
|
72
|
+
</datosCabecera>
|
73
|
+
datos
|
74
|
+
end
|
75
|
+
|
76
|
+
def post(method, fields: {})
|
77
|
+
response = super(BASE_ENDPOINT + method, fields: fields)
|
78
|
+
parse_context(response)
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def xml_products
|
84
|
+
<<-products
|
85
|
+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.isban.es/webservices/BAMOBI/Posglobal/F_bamobi_posicionglobal_lip/internet/BAMOBIPGL/v1">
|
86
|
+
#{xml_security_header}
|
87
|
+
<soapenv:Body>
|
88
|
+
<v1:obtenerPosGlobal_LIP facade="BAMOBIPGL">
|
89
|
+
<entrada>#{xml_datos_cabecera}</entrada>
|
90
|
+
</v1:obtenerPosGlobal_LIP>
|
91
|
+
</soapenv:Body>
|
92
|
+
</soapenv:Envelope>
|
93
|
+
products
|
94
|
+
end
|
95
|
+
|
96
|
+
# Build an Account object from API data
|
97
|
+
def build_account(data)
|
98
|
+
Account.new(
|
99
|
+
bank: self,
|
100
|
+
id: value_at_xpath(data, 'comunes/contratoID/NUMERO_DE_CONTRATO'),
|
101
|
+
name: value_at_xpath(data, 'comunes/descContrato'),
|
102
|
+
available_balance: money(data, 'importeDispAut'),
|
103
|
+
balance: money(data, 'impSaldoActual'),
|
104
|
+
iban: value_at_xpath(data, 'IBAN').tr(' ', ''),
|
105
|
+
description: value_at_xpath(data, 'comunes/alias') || value_at_xpath(data, 'comunes/descContrato'),
|
106
|
+
contract_id: data.at_xpath('contratoIDViejo').children.to_s
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Build an Card object from API data
|
111
|
+
def build_card(data)
|
112
|
+
Card.new(
|
113
|
+
bank: self,
|
114
|
+
id: value_at_xpath(data, 'pan'),
|
115
|
+
name: value_at_xpath(data, 'comunes/descContrato'),
|
116
|
+
available_balance: money(data, 'impDisponible'),
|
117
|
+
balance: money(data, 'impSaldoDispuesto'),
|
118
|
+
iban: value_at_xpath(data, 'comunes/contratoID'),
|
119
|
+
description: "#{value_at_xpath(data, 'comunes/alias') || value_at_xpath(data, 'comunes/descContrato')} (#{value_at_xpath(data, 'descTipoTarjeta')})",
|
120
|
+
contract_id: data.at_xpath('comunes/contratoID').children.to_s
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
def parse_context(xml)
|
125
|
+
document = Nokogiri::XML(xml)
|
126
|
+
@cookie_credential = value_at_xpath(document, '//cookieCredential', @cookie_credential)
|
127
|
+
@token_credential = value_at_xpath(document, '//tokenCredential', @token_credential)
|
128
|
+
self.user_data = document.at_xpath('//methodResult/datosUsuario') || user_data
|
129
|
+
document
|
130
|
+
end
|
131
|
+
|
132
|
+
def public_ip
|
133
|
+
log 'getting public ip'
|
134
|
+
ip = open('http://api.ipify.org').read
|
135
|
+
log "public ip: [#{ip}]"
|
136
|
+
ip
|
137
|
+
end
|
138
|
+
|
139
|
+
def format_user(user)
|
140
|
+
user.upcase
|
141
|
+
end
|
142
|
+
|
143
|
+
def xml_login(public_ip)
|
144
|
+
<<-login
|
145
|
+
<v:Envelope xmlns:v="http://schemas.xmlsoap.org/soap/envelope/" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
146
|
+
<v:Header />
|
147
|
+
<v:Body>
|
148
|
+
<n0:authenticateCredential xmlns:n0="http://www.isban.es/webservices/TECHNICAL_FACADES/Security/F_facseg_security/internet/loginServicesNSegWS/v1" facade="loginServicesNSegWS">
|
149
|
+
<CB_AuthenticationData i:type=":CB_AuthenticationData">
|
150
|
+
<documento i:type=":documento">
|
151
|
+
<CODIGO_DOCUM_PERSONA_CORP i:type="d:string">#{@user}</CODIGO_DOCUM_PERSONA_CORP>
|
152
|
+
<TIPO_DOCUM_PERSONA_CORP i:type="d:string">N</TIPO_DOCUM_PERSONA_CORP>
|
153
|
+
</documento>
|
154
|
+
<password i:type="d:string">#{@password}</password>
|
155
|
+
</CB_AuthenticationData>
|
156
|
+
<userAddress i:type="d:string">#{public_ip}</userAddress>
|
157
|
+
</n0:authenticateCredential>
|
158
|
+
</v:Body>
|
159
|
+
</v:Envelope>
|
160
|
+
login
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require_relative 'utils.rb'
|
2
|
+
|
3
|
+
module Bankscrap
|
4
|
+
module Openbank
|
5
|
+
class Card < Account
|
6
|
+
include Utils
|
7
|
+
|
8
|
+
CARD_ENDPOINT = '/OPB_BAMOBI_WS_ENS/ws/BAMOBI_WS_Def_Listener'.freeze
|
9
|
+
|
10
|
+
# Fetch transactions for the given account.
|
11
|
+
# By default it fetches transactions for the last month,
|
12
|
+
#
|
13
|
+
# Returns an array of BankScrap::Transaction objects
|
14
|
+
def fetch_transactions_for(connection, start_date: Date.today - 1.month, end_date: Date.today)
|
15
|
+
transactions = []
|
16
|
+
end_page = false
|
17
|
+
repos = nil
|
18
|
+
|
19
|
+
# Loop over pagination
|
20
|
+
until end_page
|
21
|
+
document = connection.post(CARD_ENDPOINT, fields: xml_card(connection, start_date, end_date, repos))
|
22
|
+
|
23
|
+
transactions += document.xpath('//lista/dato').map { |data| build_transaction(data) }
|
24
|
+
|
25
|
+
repos = document.at_xpath('//methodResult/repos')
|
26
|
+
end_page = value_at_xpath(document, '//methodResult/finLista') != 'N'
|
27
|
+
end
|
28
|
+
|
29
|
+
transactions
|
30
|
+
end
|
31
|
+
|
32
|
+
def xml_card(connection, from_date, to_date, repos)
|
33
|
+
is_pagination = repos ? 'S' : 'N'
|
34
|
+
xml_from_date = xml_date(from_date)
|
35
|
+
xml_to_date = xml_date(to_date)
|
36
|
+
<<-card
|
37
|
+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.isban.es/webservices/BAMOBI/Tarjetas/F_bamobi_tarjetas_lip/internet/BAMOBITAJ/v1">
|
38
|
+
#{connection.xml_security_header}
|
39
|
+
<soapenv:Body>
|
40
|
+
<v1:listaMovTarjetasFechas_LIP facade="BAMOBITAJ">
|
41
|
+
<entrada>
|
42
|
+
<datosConexion>#{connection.user_data.children}</datosConexion>
|
43
|
+
#{connection.xml_datos_cabecera}
|
44
|
+
<contratoTarjeta>#{contract_id}</contratoTarjeta>
|
45
|
+
<numeroTarj>#{id}</numeroTarj>
|
46
|
+
<fechaDesde>#{xml_from_date}</fechaDesde>
|
47
|
+
<fechaHasta>#{xml_to_date}</fechaHasta>
|
48
|
+
<esUnaPaginacion>#{is_pagination}</esUnaPaginacion>
|
49
|
+
#{repos}
|
50
|
+
</entrada>
|
51
|
+
</v1:listaMovTarjetasFechas_LIP>
|
52
|
+
</soapenv:Body>
|
53
|
+
</soapenv:Envelope>
|
54
|
+
card
|
55
|
+
end
|
56
|
+
|
57
|
+
def xml_date(date)
|
58
|
+
"<dia>#{date.day}</dia><mes>#{date.month}</mes><anyo>#{date.year}</anyo>"
|
59
|
+
end
|
60
|
+
|
61
|
+
# Build a transaction object from API data
|
62
|
+
def build_transaction(data)
|
63
|
+
Transaction.new(
|
64
|
+
account: self,
|
65
|
+
id: value_at_xpath(data, 'movimDia'),
|
66
|
+
amount: money(data, 'importeMovto'),
|
67
|
+
description: value_at_xpath(data, 'descMovimiento'),
|
68
|
+
effective_date: Date.strptime(value_at_xpath(data, 'fechaAnota'), '%Y-%m-%d'),
|
69
|
+
# operation_date: Date.strptime(value_at_xpath(data, 'fechaOpera'), "%Y-%m-%d"),
|
70
|
+
balance: Money.new(0, 'EUR') # TODO: Prepaid/debit cards don't have a Balance - maybe Credit ones do.
|
71
|
+
)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Bankscrap
|
2
|
+
module Openbank
|
3
|
+
module Utils
|
4
|
+
def value_at_xpath(node, xpath, default = '')
|
5
|
+
value = node.at_xpath(xpath)
|
6
|
+
value ? value.content.strip : default
|
7
|
+
end
|
8
|
+
|
9
|
+
def money(data, xpath)
|
10
|
+
Money.new(
|
11
|
+
value_at_xpath(data, xpath + '/IMPORTE').delete('.'),
|
12
|
+
value_at_xpath(data, xpath + '/DIVISA')
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bankscrap-openbank
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- zjuanma
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-29 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '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.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '8.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- zjuanma@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- Gemfile
|
77
|
+
- LICENSE.txt
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- bankscrap-openbank.gemspec
|
81
|
+
- lib/bankscrap-openbank.rb
|
82
|
+
- lib/bankscrap/openbank/account.rb
|
83
|
+
- lib/bankscrap/openbank/bank.rb
|
84
|
+
- lib/bankscrap/openbank/card.rb
|
85
|
+
- lib/bankscrap/openbank/utils.rb
|
86
|
+
- lib/bankscrap/openbank/version.rb
|
87
|
+
homepage: https://github.com/zjuanma/bankscrap-openbank
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.4.8
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Openbank adapter for Bankscrap
|
111
|
+
test_files: []
|