sbifapi 0.0.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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +0 -0
  3. data/lib/sbif.rb +45 -0
  4. data/sbif.gemspec +12 -0
  5. metadata +47 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed9b6d6b514cff1b0506c3de6c3ea4b70cd5f0fa
4
+ data.tar.gz: a82bf6916d352e5f4ba6f6d732d174abe8f9ac3f
5
+ SHA512:
6
+ metadata.gz: 03d80d5f4233bcc931cab9b072ae8f477a1824349b5b5c07e95d1a04e6c0c89b4d82e808f4504b89c8e3294f5c08afb69a33e58f48849f8b39699f8a8bf1db08
7
+ data.tar.gz: 3ce112792717a06bc376e32d4be97ef8592c0b1c9ccfad2cfff3813abd36612662027d361c0aecec68c9bba3c77296b01843fd47c3ddc94c5ee421a7317a4a24
File without changes
@@ -0,0 +1,45 @@
1
+ require 'net/http'
2
+ require 'json'
3
+ require 'date'
4
+
5
+ class SBIF
6
+
7
+ def initialize(api_key)
8
+ @base_url = "http://api.sbif.cl/api-sbifv3/recursos_api/%{indicator}?apikey=#{api_key}&formato=json"
9
+ end
10
+
11
+ def uf
12
+ url = URI(@base_url % {indicator: 'uf'})
13
+ {'Valor': JSON.parse(Net::HTTP.get(url))['UFs'][0]['Valor']}
14
+ end
15
+
16
+ def dolar
17
+ url = URI(@base_url % {indicator: 'dolar'})
18
+ {'Valor': JSON.parse(Net::HTTP.get(url))['Dolares'][0]['Valor']}
19
+ end
20
+
21
+ def ipc
22
+ url = URI(@base_url % {indicator: 'ipc'})
23
+ {'Valor': JSON.parse(Net::HTTP.get(url))['IPCs'][0]['Valor']}
24
+ end
25
+
26
+ def tmc
27
+ url = URI(@base_url % {indicator: "tmc/#{Date.today.year}"})
28
+ tmcs = []
29
+ JSON.parse(Net::HTTP.get(url))['TMCs'].each do |tmc|
30
+ tmcs << {'Tasa': "#{tmc['Titulo']}|#{tmc['SubTitulo']}", 'Valor': tmc['Valor'] }
31
+ end
32
+ tmcs
33
+ end
34
+
35
+ def euro
36
+ url = URI(@base_url % {indicator: 'euro'})
37
+ {'Valor': JSON.parse(Net::HTTP.get(url))['Euros'][0]['Valor']}
38
+ end
39
+
40
+ def utm
41
+ url = URI(@base_url % {indicator: 'utm'})
42
+ {'Valor': JSON.parse(Net::HTTP.get(url))['UTMs'][0]['Valor']}
43
+ end
44
+
45
+ end
@@ -0,0 +1,12 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'sbifapi'
3
+ s.version = '0.0.1'
4
+ s.platform = Gem::Platform::RUBY
5
+ s.authors = ['Nicolás Kipreos']
6
+ s.email = ['nkipreos@gmail.com']
7
+ s.homepage = 'http://github.com/nkipreos/'
8
+ s.description = 'A Ruby Library for the SBIF Chile'
9
+ s.summary = 'This is a library for the API of the Superintendencia de Bancos e Instituciones Financieras'
10
+ s.files = Dir.glob('{lib}/**/*') + %w(README.md sbif.gemspec)
11
+ s.require_path = 'lib'
12
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sbifapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nicolás Kipreos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Ruby Library for the SBIF Chile
14
+ email:
15
+ - nkipreos@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.md
21
+ - lib/sbif.rb
22
+ - sbif.gemspec
23
+ homepage: http://github.com/nkipreos/
24
+ licenses: []
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.4.5.1
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: This is a library for the API of the Superintendencia de Bancos e Instituciones
46
+ Financieras
47
+ test_files: []