afterbanks-api-ruby 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b950e0c205ccad340e3151cf3b30e059ede78eaa2537decdf34df8f5069ca00d
4
- data.tar.gz: 297d4e9482c49b6c3513d5d33a005456490411b2337e9f4c287e23dddbe3807e
3
+ metadata.gz: 19bc05050d36cdf980cc1d2ab883c6b82f4ed4622fa959cebaa80099b5a40716
4
+ data.tar.gz: a5ffd80b0e31ee743d903564909ba692839c34a390eab12bcec6948719b56b6b
5
5
  SHA512:
6
- metadata.gz: c8b8e439e5c5d28925050f97f0bff83d8358b492c13f3b9ba7f4f437b6819a821c1515d291d08d3152e05d7e455cb5a2b9315d11f78a87eaf2da9e7cb06b1d1a
7
- data.tar.gz: d59b18b57fb1a0f7acad963cce8faf2b50fbe4ae5f5c7c27dd6940b240ea5284d9dff83c0430aafdcc21ed86faba26ecb8a6447c325a9b5e74b4dc6ded90f2c8
6
+ metadata.gz: 89335c1312001084d537c486f800d3d46fc252b80a634d970b68120210888cbc2e9ba66ee80f331da86cd813c8362081c25f4c91da8501bf6e0157970a4aea51
7
+ data.tar.gz: e97843bdfd06e003e5ba6136e8e237084e5b0d43c0ad347c221f42586936772c099bf2a2cf59ec57a8363db0b6b600304e21ad0f36d629f83fba70de44f5719c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- afterbanks-api-ruby (0.2.0)
4
+ afterbanks-api-ruby (0.2.1)
5
5
  rest-client (~> 2.0.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -33,7 +33,8 @@ You can set a `logger` as well.
33
33
  Changelog
34
34
  ---------
35
35
 
36
- * v.0.1.2 Allow adding an (opt-in) random parameter to Afterbanks::Account.list to avoid caching
36
+ * v.0.2.1 Better naming for banks
37
+ * v.0.2.0 Allow adding an (opt-in) random parameter to Afterbanks::Account.list to avoid caching
37
38
  * v.0.1.1 Fix rake security issue and remove specific Ruby version dependency.
38
39
  * v.0.1.0 First vull version, including resource wrapping (for banks, accounts, transactions and the user) and separate exceptions for each different code.
39
40
 
@@ -24,16 +24,11 @@ module Afterbanks
24
24
  path: '/forms/'
25
25
  )
26
26
 
27
- if ordered
28
- response.sort! do |bank1, bank2|
29
- bank1['fullname'].downcase <=> bank2['fullname'].downcase
30
- end
31
- end
32
-
33
27
  Response.new(
34
28
  result: Collection.new(
35
29
  banks_information_for(
36
- response: response
30
+ response: response,
31
+ ordered: ordered
37
32
  ),
38
33
  self
39
34
  ),
@@ -43,18 +38,54 @@ module Afterbanks
43
38
 
44
39
  private
45
40
 
46
- def self.banks_information_for(response:)
41
+ def self.banks_information_for(response:, ordered:)
47
42
  banks_information = []
48
43
 
44
+ services_number_by_bank_id = {}
45
+ response.each { |bank_information|
46
+ bank_id = bank_id_for(bank_information: bank_information)
47
+ services_number_by_bank_id[bank_id] ||= 0
48
+ services_number_by_bank_id[bank_id] += 1
49
+ }
50
+
49
51
  response.each do |bank_information|
50
- if bank_information['business'] == "1"
51
- bank_information['fullname'] += " Empresas"
52
- end
52
+ bank_information['fullname'] = bank_name_for(
53
+ bank_information: bank_information,
54
+ services_number_by_bank_id: services_number_by_bank_id
55
+ )
53
56
 
54
57
  banks_information << bank_information
55
58
  end
56
59
 
60
+ if ordered
61
+ banks_information.sort! do |bank_information1, bank_information2|
62
+ bank_information1['fullname'].downcase <=> bank_information2['fullname'].downcase
63
+ end
64
+ end
65
+
57
66
  banks_information
58
67
  end
68
+
69
+ def self.bank_name_for(bank_information:, services_number_by_bank_id:)
70
+ if bank_information['service'] == 'cajaingenieros'
71
+ return "Caixa d'Enginyers"
72
+ end
73
+
74
+ fullname = bank_information['fullname']
75
+ if bank_information['business'] == "1"
76
+ return "#{fullname} Empresas"
77
+ end
78
+
79
+ bank_id = bank_id_for(bank_information: bank_information)
80
+ if services_number_by_bank_id[bank_id] > 1
81
+ return "#{fullname} Particulares"
82
+ end
83
+
84
+ fullname
85
+ end
86
+
87
+ def self.bank_id_for(bank_information:)
88
+ bank_information['service'].split("_").first
89
+ end
59
90
  end
60
91
  end
@@ -1,3 +1,3 @@
1
1
  module Afterbanks
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: afterbanks-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Bellonch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-29 00:00:00.000000000 Z
11
+ date: 2020-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client