santander_chile-api_client 0.0.2 → 1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +25 -4
- data/lib/santander_chile/api_client/collection.rb +5 -0
- data/lib/santander_chile/api_client/endpoints.rb +3 -3
- data/lib/santander_chile/api_client/models/movement.rb +53 -0
- data/lib/santander_chile/api_client/resources/movements.rb +32 -0
- data/lib/santander_chile/api_client/version.rb +1 -1
- data/lib/santander_chile/api_client.rb +7 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 771a6b84cdb5be50f473e910aea00e9afe3f458d91674aaa5f5487deae311f5b
|
4
|
+
data.tar.gz: fcb01d7f84b575f907b7c429b936b827263a8d69e6739565254d20c3cbf5dd4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2379249a58802e803829e4dd8c0f2cf9555ba4841dabc4f672ba6b9e2a7c2b3f331721e1cbcf9c24a38898ed7a8674e7ba454ffec30319ff8a9a573da346b896
|
7
|
+
data.tar.gz: fa7105defabcb5c31451d640097419df0ac80f8e305d755686aa96d76ba1eb3d9a01e74c1a13a98581462c66ae92f1aca82a79882e7f1101c900594ef64377b3
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -38,16 +38,37 @@ client.login(
|
|
38
38
|
|
39
39
|
#### Products (accounts)
|
40
40
|
```rb
|
41
|
-
results = client.products
|
41
|
+
results = client.products
|
42
42
|
#=> SantanderChile::ApiClient::Collection
|
43
43
|
|
44
|
-
results.
|
45
|
-
#=>
|
44
|
+
results.each { |x| x }
|
45
|
+
#=> <SantanderChile::ApiClient::Account>
|
46
|
+
#=> <SantanderChile::ApiClient::Account:>
|
47
|
+
#=> <SantanderChile::ApiClient::Account>
|
48
|
+
|
49
|
+
account = result.first
|
50
|
+
#=> <SantanderChile::ApiClient::Account>
|
51
|
+
|
52
|
+
```
|
53
|
+
#### Movements
|
54
|
+
```rb
|
55
|
+
movements = client.movements(account)
|
56
|
+
#=> SantanderChile::ApiClient::Collection
|
57
|
+
|
58
|
+
movements.each { |x| x }
|
59
|
+
#=> <SantanderChile::ApiClient::Movement *empty movement*>
|
60
|
+
#=> <SantanderChile::ApiClient::Movement>
|
61
|
+
#=> <SantanderChile::ApiClient::Movement>
|
62
|
+
|
63
|
+
# ** For some reason, the api return a list with and empty first element
|
64
|
+
|
46
65
|
```
|
66
|
+
|
67
|
+
|
47
68
|
### Todo
|
48
69
|
- [x] ~~Products (accounts)~~
|
70
|
+
- [x] ~~Movements~~
|
49
71
|
- [ ] Balance
|
50
|
-
- [ ] Transactions
|
51
72
|
- [ ] Transfers
|
52
73
|
- [ ] Payments
|
53
74
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module SantanderChile
|
2
2
|
module ApiClient
|
3
3
|
class Collection
|
4
|
+
include Enumerable
|
4
5
|
attr_reader :data
|
5
6
|
|
6
7
|
def initialize(data:)
|
@@ -16,6 +17,10 @@ module SantanderChile
|
|
16
17
|
},
|
17
18
|
)
|
18
19
|
end
|
20
|
+
|
21
|
+
def each(*args, &block)
|
22
|
+
@data.each(*args, &block)
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -10,9 +10,9 @@ module SantanderChile
|
|
10
10
|
"PATH": "ConsultaSaldo",
|
11
11
|
"KEYS_TO": ["DATA", "AS_TIB_Consulta_Saldo_Response", "OUTPUT", "ESCALARES"],
|
12
12
|
}
|
13
|
-
|
14
|
-
"PATH": "MvtosYDeposiDocCtas",
|
15
|
-
"KEYS_TO": [],
|
13
|
+
MOVEMENTS = {
|
14
|
+
"PATH": "Consultas/MvtosYDeposiDocCtas",
|
15
|
+
"KEYS_TO": ["DATA", "MovimientosDepositos"],
|
16
16
|
}
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module SantanderChile
|
2
|
+
module ApiClient
|
3
|
+
class Movement < Object
|
4
|
+
ATTRIBUTES = {
|
5
|
+
"record_type" => "TipReg",
|
6
|
+
"transaction_number" => "NumMov",
|
7
|
+
"code" => "Codigo",
|
8
|
+
"amount" => "Importe",
|
9
|
+
# "" => "Concepto",
|
10
|
+
"post_date" => "FechConta",
|
11
|
+
"transaction_date" => "FechOper",
|
12
|
+
"transaction_time" => "HoraOper",
|
13
|
+
#"" => "FechValor",
|
14
|
+
#"" => "Cheque",
|
15
|
+
"balance" => "NuevoSaldo",
|
16
|
+
# "" => "IndAomo",
|
17
|
+
# "" => "IndAct",
|
18
|
+
# "" => "IndAnulab",
|
19
|
+
# "" => "IndAnulado",
|
20
|
+
# "" => "IndCargabo",
|
21
|
+
# "" => "IndGiro",
|
22
|
+
# "" => "Codigur",
|
23
|
+
# "" => "TipoCambio",
|
24
|
+
# "canal" => "Canal",
|
25
|
+
# "" => "IndPpal",
|
26
|
+
# "" => "Transaccion",
|
27
|
+
# "" => "CodAplicac",
|
28
|
+
# "" => "TermNio",
|
29
|
+
# "" => "FechNio",
|
30
|
+
# "" => "HoraNio",
|
31
|
+
|
32
|
+
"ConcepAmp" => "ConcepAmp",
|
33
|
+
"CodigoAmp" => "CodigoAmp",
|
34
|
+
"EntidadUmo" => "EntidadUmo",
|
35
|
+
"CentroUmo" => "CentroUmo",
|
36
|
+
"UseridUmo" => "UseridUmo",
|
37
|
+
"CajeroUmo" => "CajeroUmo",
|
38
|
+
|
39
|
+
"annotation" => "Observa",
|
40
|
+
"reference" => "ReferMvto",
|
41
|
+
# "" => "TipDep",
|
42
|
+
# "" => "DivDep",
|
43
|
+
# "" => "CentroDep",
|
44
|
+
# "" => "NumPapeleta",
|
45
|
+
# "" => "IndRetEsp",
|
46
|
+
# "" => "TimeUmo",
|
47
|
+
|
48
|
+
}
|
49
|
+
|
50
|
+
attr_accessor(*ATTRIBUTES.keys.map { |x| x.to_sym })
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module SantanderChile
|
2
|
+
module ApiClient
|
3
|
+
class MovementsResource < Resource
|
4
|
+
## PATHS on santander_chile/api_client/endpoints.rb
|
5
|
+
def movements_params(client, account)
|
6
|
+
{
|
7
|
+
"Cabecera" => {
|
8
|
+
"HOST" => {
|
9
|
+
"USUARIO-ALT" => "GHOBP",
|
10
|
+
"TERMINAL-ALT" => "",
|
11
|
+
"CANAL-ID" => "078",
|
12
|
+
},
|
13
|
+
"CanalFisico" => "78",
|
14
|
+
"CanalLogico" => "74",
|
15
|
+
"RutCliente" => client.username,
|
16
|
+
"RutUsuario" => client.username,
|
17
|
+
"IpCliente" => "",
|
18
|
+
"InfoDispositivo" => "xx",
|
19
|
+
},
|
20
|
+
"Entrada" => {
|
21
|
+
"NumeroCuenta" => account.account_number,
|
22
|
+
},
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def list(account, *params)
|
27
|
+
response = post_request(MOVEMENTS[:PATH], body: movements_params(@client, account).to_json)
|
28
|
+
Collection.from_response(response, keys_to: MOVEMENTS[:KEYS_TO], type: Movement)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -10,10 +10,12 @@ module SantanderChile
|
|
10
10
|
|
11
11
|
autoload :Object, "santander_chile/api_client/models/object"
|
12
12
|
autoload :Account, "santander_chile/api_client/models/account"
|
13
|
+
autoload :Movement, "santander_chile/api_client/models/movement"
|
13
14
|
autoload :Collection, "santander_chile/api_client/collection"
|
14
15
|
|
15
16
|
autoload :Resource, "santander_chile/api_client/resources/resource"
|
16
17
|
autoload :ProductsResource, "santander_chile/api_client/resources/products"
|
18
|
+
autoload :MovementsResource, "santander_chile/api_client/resources/movements"
|
17
19
|
|
18
20
|
class Client
|
19
21
|
autoload :Configuration, "santander_chile/api_client/client/configuration"
|
@@ -34,7 +36,11 @@ module SantanderChile
|
|
34
36
|
end
|
35
37
|
|
36
38
|
def products
|
37
|
-
ProductsResource.new(self)
|
39
|
+
ProductsResource.new(self).list
|
40
|
+
end
|
41
|
+
|
42
|
+
def movements(account)
|
43
|
+
MovementsResource.new(self).list(account)
|
38
44
|
end
|
39
45
|
end
|
40
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: santander_chile-api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerry Mendoza
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -64,7 +64,9 @@ files:
|
|
64
64
|
- lib/santander_chile/api_client/endpoints.rb
|
65
65
|
- lib/santander_chile/api_client/error.rb
|
66
66
|
- lib/santander_chile/api_client/models/account.rb
|
67
|
+
- lib/santander_chile/api_client/models/movement.rb
|
67
68
|
- lib/santander_chile/api_client/models/object.rb
|
69
|
+
- lib/santander_chile/api_client/resources/movements.rb
|
68
70
|
- lib/santander_chile/api_client/resources/products.rb
|
69
71
|
- lib/santander_chile/api_client/resources/resource.rb
|
70
72
|
- lib/santander_chile/api_client/token.rb
|