bcn_ni 0.1.4 → 0.1.7

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: 3f0e01abc9ca4e65e1f22527f880650253b861badbd36e6b7f4c387e44a0fc04
4
- data.tar.gz: c9b29f47fca3b6dec463b896b665ab65907f22ad45645941ab06a1e806d265fc
3
+ metadata.gz: 2d17fe676aa77facf97c9cf4355d7de85a4ff7f3f0f047324b56201992264092
4
+ data.tar.gz: 65cb53118d9f3086d96d29c41fd5c5745f1ca789f91b8e04b9da2a6545cf25f7
5
5
  SHA512:
6
- metadata.gz: 677ca5cc3b6f864b40e4573ad0fe0c978ec3929b6262eb1212f9ec9455ddfe107b268db429af33cdbf97a70b20a325a56922335736130600e760201f20b46157
7
- data.tar.gz: ed2a566e0fc5477a53fbd9c24abbc0f22ac7adee37c397857a10dd2beeceaffb675aae64c0910ffc37acc66154026ebe2ee76ba5082416c83f6d75fef7ace016
6
+ metadata.gz: 7312305624a80c519b8956faad2c1faecaa3cc93f2e59dbc194b6b991c9958deb91f27686df5cbbb07648115066833935e37d7aa164f62e2cdbb08ba8c80974a
7
+ data.tar.gz: 99f45ec56e4e64b7382853c8fa0abeff6839f9a65a2bfbb3c626fa262a445f6a795bcf6f00a4424b4b833fc04fcad55f2111e76f662fc94de62c00202e9eba87
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # BcnNi
2
+
2
3
  This gem provides NIO (Córdoba Oro Nicaragüense) against USD (United States Dollar) money exchange rates consuming the official Central Bank of Nicaragüa (BCN) SOAP Service or HTML page
3
4
 
4
5
  ## Basic usage
6
+
5
7
  ```ruby
6
8
  # Returns the exchange rate for September 15th, 2017
7
9
  day_rate = BcnNi.exchange_day(2017, 9, 15)
@@ -47,6 +49,7 @@ month_rate = BcnNi.exchange_month(2017, 9)
47
49
  ```
48
50
 
49
51
  ## Changing the request mode
52
+
50
53
  For changing the request mode simply add `request_mode` argument at the end of the method args. **The default request mode is scrapping** (which incredibly resulted to be faster than SOAP and with 24/7 availability). You can change this like the example given below:
51
54
 
52
55
  ```ruby
@@ -58,8 +61,8 @@ day_rate = BcnNi.exchange_day(2017, 9, 15, request_mode: :soap)
58
61
  month_rate = BcnNi.exchange_month(2017, 9, request_mode: :soap)
59
62
  ```
60
63
 
61
-
62
64
  ## Installation
65
+
63
66
  Add this line to your application's Gemfile:
64
67
 
65
68
  ```ruby
@@ -67,19 +70,29 @@ Add this line to your application's Gemfile:
67
70
  gem 'bcn_ni', git: 'https://github.com/mldoscar/bcn_ni', branch: 'master'
68
71
 
69
72
  # From ruby gems
70
- gem 'bcn_ni', '>= 0.1.4'
73
+ gem 'bcn_ni', '~> 0.1.7'
71
74
 
72
75
  # Using gem install
73
76
  gem install bcn_ni
74
77
  ```
75
78
 
76
79
  And then execute:
80
+
77
81
  ```bash
78
82
  $ bundle
79
83
  ```
80
84
 
85
+ ## Changelog
86
+
87
+ ```
88
+ 2022.04.06 - Rails 6.x 7.x compatibility
89
+ 2021.06.28 - Bugfix: Cambio en el URI para el request de scrapping, el BCN cambió de parámetros y ubicación de URL
90
+ ```
91
+
81
92
  ## Contributing
93
+
82
94
  You guys are free to send your pull requests for contributing. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
83
95
 
84
96
  ## License
97
+
85
98
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -3,8 +3,13 @@ require 'net/http'
3
3
  require 'net/https'
4
4
  require 'nokogiri'
5
5
  require 'open-uri'
6
- require 'active_support/core_ext/hash'
7
6
  require 'json'
7
+ require 'active_support/core_ext/hash'
8
+ begin
9
+ require 'active_support/time'
10
+ rescue LoadError
11
+ end
12
+
8
13
 
9
14
  module BcnNi
10
15
  class Request
@@ -30,7 +35,7 @@ module BcnNi
30
35
 
31
36
  case @request_mode
32
37
  when :scrapping
33
- @request_url = "https://www.bcn.gob.ni/estadisticas/mercados_cambiarios/tipo_cambio/cordoba_dolar/mes.php"
38
+ @request_url = "https://www.bcn.gob.ni/IRR/tipo_cambio_mensual/mes.php"
34
39
  when :soap
35
40
  # See 'https://servicios.bcn.gob.ni/Tc_Servicio/ServicioTC.asmx' for more info about how to build a RAW SOAP request
36
41
  @request_url = "https://servicios.bcn.gob.ni/Tc_Servicio/ServicioTC.asmx?WSDL"
@@ -79,12 +84,11 @@ module BcnNi
79
84
  def scra__exchange_month(year, month)
80
85
  # Parse the date
81
86
  start_date = Date.new(year, month, 1)
82
- end_date = start_date.end_of_month
83
87
 
84
88
  # Create the arg hash
85
89
  args = {
86
- Fecha_inicial: start_date,
87
- Fecha_final: end_date
90
+ mes: start_date.strftime('%m'),
91
+ anio: start_date.strftime('%Y')
88
92
  }
89
93
 
90
94
  # Generate the full url
@@ -194,35 +198,35 @@ module BcnNi
194
198
  end
195
199
 
196
200
  def soap__envelope(letter)
197
- envelope = <<EOF
201
+ envelope = <<-XML
198
202
  <?xml version="1.0" encoding="utf-8"?>
199
203
  <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
200
204
  <soap:Body>
201
205
  #{letter}
202
206
  </soap:Body>
203
207
  </soap:Envelope>
204
- EOF
208
+ XML
205
209
  return envelope
206
210
  end
207
211
 
208
212
  def soap__letter_exchange_day(year, month, day)
209
- letter = <<EOF
213
+ letter = <<-XML
210
214
  <RecuperaTC_Dia xmlns="http://servicios.bcn.gob.ni/">
211
215
  <Ano>#{year}</Ano>
212
216
  <Mes>#{month}</Mes>
213
217
  <Dia>#{day}</Dia>
214
218
  </RecuperaTC_Dia>
215
- EOF
219
+ XML
216
220
  return letter
217
221
  end
218
222
 
219
223
  def soap__letter_exchange_month(year, month)
220
- letter = <<EOF
224
+ letter = <<-XML
221
225
  <RecuperaTC_Mes xmlns="http://servicios.bcn.gob.ni/">
222
226
  <Ano>#{year}</Ano>
223
227
  <Mes>#{month}</Mes>
224
228
  </RecuperaTC_Mes>
225
- EOF
229
+ XML
226
230
  return letter
227
231
  end
228
232
 
@@ -1,3 +1,3 @@
1
1
  module BcnNi
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcn_ni
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Rodriguez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-15 00:00:00.000000000 Z
11
+ date: 2022-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '5.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '5.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: nokogiri
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -88,7 +94,7 @@ homepage: https://github.com/mldoscar/bcn_ni
88
94
  licenses:
89
95
  - MIT
90
96
  metadata: {}
91
- post_install_message:
97
+ post_install_message:
92
98
  rdoc_options: []
93
99
  require_paths:
94
100
  - lib
@@ -103,9 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
109
  - !ruby/object:Gem::Version
104
110
  version: '0'
105
111
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.7.7
108
- signing_key:
112
+ rubygems_version: 3.0.6
113
+ signing_key:
109
114
  specification_version: 4
110
115
  summary: This tool pretends to be helpful for developers who can request exchange
111
116
  rates from Nicaragua in a easier way