bci 17.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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +48 -0
- data/LICENSE +21 -0
- data/README.md +98 -0
- data/bci.gemspec +29 -0
- data/lib/bci.rb +12 -0
- data/lib/bci/base.rb +38 -0
- data/lib/bci/beneficios.rb +52 -0
- data/lib/bci/client.rb +33 -0
- data/lib/bci/consumo.rb +16 -0
- data/lib/bci/hipotecario.rb +33 -0
- data/lib/bci/stats.rb +32 -0
- data/lib/bci/version.rb +3 -0
- data/spec/spec_helper.rb +2 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e6bdcabe91bce161ac89ff9a419d1fc3e78b7f9e
|
4
|
+
data.tar.gz: 8852277c1bce046eafefab5145ef1b0bff2a226c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4f8292032f062a7adc7d06bea5e868ac50ce819968b830f4ac7efa4b81005cc0bf54e7729f57e5d7123aa3c5722d1d450025364d8c6cb6fad086cbee2db0d24
|
7
|
+
data.tar.gz: b57e7b644b4ded8f39867beb73f375aef41a485ed93fe8497ea962477f0349780ad62042c258ddb0fc57e00d9af02f6c660e632f865745be845834dc779573cd
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bci (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
domain_name (0.5.20170404)
|
11
|
+
unf (>= 0.0.5, < 1.0.0)
|
12
|
+
http-cookie (1.0.3)
|
13
|
+
domain_name (~> 0.5)
|
14
|
+
mime-types (3.1)
|
15
|
+
mime-types-data (~> 3.2015)
|
16
|
+
mime-types-data (3.2016.0521)
|
17
|
+
netrc (0.11.0)
|
18
|
+
rest-client (2.0.2)
|
19
|
+
http-cookie (>= 1.0.2, < 2.0)
|
20
|
+
mime-types (>= 1.16, < 4.0)
|
21
|
+
netrc (~> 0.8)
|
22
|
+
rspec (3.6.0)
|
23
|
+
rspec-core (~> 3.6.0)
|
24
|
+
rspec-expectations (~> 3.6.0)
|
25
|
+
rspec-mocks (~> 3.6.0)
|
26
|
+
rspec-core (3.6.0)
|
27
|
+
rspec-support (~> 3.6.0)
|
28
|
+
rspec-expectations (3.6.0)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.6.0)
|
31
|
+
rspec-mocks (3.6.0)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.6.0)
|
34
|
+
rspec-support (3.6.0)
|
35
|
+
unf (0.1.4)
|
36
|
+
unf_ext
|
37
|
+
unf_ext (0.0.7.4)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
bci!
|
44
|
+
rest-client
|
45
|
+
rspec (~> 3)
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
1.12.5
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Programadores Chile ®
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
BCI API Ruby Client
|
2
|
+
=================
|
3
|
+
|
4
|
+
An API client that comes handy to connect with BCI developers API.
|
5
|
+
|
6
|
+
## Setup
|
7
|
+
|
8
|
+
Install with `gem install bci` or add to your Gemfile :)
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
Create a new client object with the api key in a hash:
|
13
|
+
|
14
|
+
```
|
15
|
+
client = Bci::Client.new({ key: YOUR_KEY })
|
16
|
+
```
|
17
|
+
|
18
|
+
The client is a proxy for the endpoints managers. Currently, there are four supported
|
19
|
+
sections of the BCI API:
|
20
|
+
|
21
|
+
1. Beneficios
|
22
|
+
|
23
|
+
To access the "beneficios" sections you can call this method on the client:
|
24
|
+
|
25
|
+
```
|
26
|
+
client.beneficios.api_method
|
27
|
+
```
|
28
|
+
|
29
|
+
`api_method` could be one of this:
|
30
|
+
|
31
|
+
- shopping: [GET] Access to the BCI shopping benefits info.
|
32
|
+
- store: [GET] Access to the BCI store benefits info.
|
33
|
+
- health_and_beauty: [GET] Access to the BCI health_and_beauty benefits info.
|
34
|
+
- online_sales: [GET] Access to the BCI online_sales benefits info.
|
35
|
+
- outdoors: [GET] Access to the BCI outdoors benefits info.
|
36
|
+
- flavors: [GET] Access to the BCI flavors benefits info.
|
37
|
+
|
38
|
+
2. Consumo
|
39
|
+
|
40
|
+
To access the "consumo" section you can call this method on the client:
|
41
|
+
|
42
|
+
```
|
43
|
+
client.consumo.api_method
|
44
|
+
```
|
45
|
+
|
46
|
+
`api_method` could be one of this:
|
47
|
+
|
48
|
+
- simulate(params): [POST] Access to the BCI consumo simulator. `params` is a hash object containing the required data according to BCI documentation.
|
49
|
+
|
50
|
+
3. Hipotecario
|
51
|
+
|
52
|
+
To access the "hipotecario" section you can call this method on the client:
|
53
|
+
|
54
|
+
```
|
55
|
+
client.hipotecario.api_method
|
56
|
+
```
|
57
|
+
|
58
|
+
`api_method` could be one of this:
|
59
|
+
|
60
|
+
- simulate(id, params): [POST] Access to the BCI hipotecario simulator.
|
61
|
+
`id` is a numeric identifier according to BCI documentation.
|
62
|
+
`params` is a hash object containing the required data according to BCI documentation.
|
63
|
+
|
64
|
+
- all: [GET] Access to the BCI list of all hipotecario products.
|
65
|
+
|
66
|
+
- find(id): [GET] Access to the detailed information of one of the hipotecario products.
|
67
|
+
`id` is a numeric identifier according to BCI documentation
|
68
|
+
|
69
|
+
- find_rates(id): [GET] Access to the rates of an hipotecario product.
|
70
|
+
|
71
|
+
4. Stats
|
72
|
+
|
73
|
+
To access the "stats" section you can call this method on the client:
|
74
|
+
|
75
|
+
```
|
76
|
+
client.stats.api_method
|
77
|
+
```
|
78
|
+
|
79
|
+
`api_method` could be one of this:
|
80
|
+
|
81
|
+
- indicators: [GET] Access to BCI economics indicators.
|
82
|
+
|
83
|
+
- branch_offices: [GET] Access to a detailed information about BCI branch offices.
|
84
|
+
|
85
|
+
- atm: [GET] Access to a detailed information about BCI ATMs (in spanish cajeros automáticos).
|
86
|
+
|
87
|
+
## Development
|
88
|
+
|
89
|
+
When hacking on this gem, the REPL `pry` comes in handy. You can load the
|
90
|
+
contents of the gem with `pry --gem`.
|
91
|
+
|
92
|
+
### Disclaimer
|
93
|
+
|
94
|
+
This was rushed for a Angelhack + BCI Labs + Programadores Chile hackathon so this doesn't have any tests :(. Yes, I know...shame on me. But feel free to contribute and make this gem better and better.
|
95
|
+
|
96
|
+
## Contributors
|
97
|
+
|
98
|
+
- Daniel Ochoa (@dochoaj)
|
data/bci.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path("../lib/bci/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
#Metadata
|
6
|
+
s.name = "bci"
|
7
|
+
s.version = Bci::VERSION
|
8
|
+
s.authors = ["Daniel Ochoa John"]
|
9
|
+
s.email = ["dochoajohn@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{A SDK to connect to BCI developers API}
|
12
|
+
s.description = %q{A SDK to connect with BCI developers API}
|
13
|
+
s.licenses = ['Nonstandard']
|
14
|
+
# If you want to show a post-install message, uncomment the following lines
|
15
|
+
# s.post_install_message = <<-MSG
|
16
|
+
#
|
17
|
+
#MSG
|
18
|
+
|
19
|
+
#Manifest
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ['lib']
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
s.add_development_dependency 'rspec', '~> 3'
|
28
|
+
|
29
|
+
end
|
data/lib/bci.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# The BCI main module
|
2
|
+
module Bci
|
3
|
+
require 'json'
|
4
|
+
require 'rest-client'
|
5
|
+
require 'bci/client'
|
6
|
+
require 'bci/version'
|
7
|
+
require 'bci/hipotecario'
|
8
|
+
require 'bci/consumo'
|
9
|
+
require 'bci/beneficios'
|
10
|
+
require 'bci/stats'
|
11
|
+
# This is your gem's load point. Require your components here.
|
12
|
+
end
|
data/lib/bci/base.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Bci
|
2
|
+
# The base class for all api clients
|
3
|
+
class Base
|
4
|
+
BASE_URL = 'https://api.us.apiconnect.ibmcloud.com/portal-api-developers-desarrollo/sandbox'.freeze
|
5
|
+
|
6
|
+
def initialize(key = nil)
|
7
|
+
@api_key = key
|
8
|
+
end
|
9
|
+
|
10
|
+
def url
|
11
|
+
"#{BASE_URL}/#{submodule}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def connector
|
15
|
+
raise 'Undefined key' unless @api_key
|
16
|
+
RestClient
|
17
|
+
end
|
18
|
+
|
19
|
+
def headers
|
20
|
+
{
|
21
|
+
'x-ibm-client-id' => @api_key,
|
22
|
+
accept: 'application/json',
|
23
|
+
content_type: 'application/json'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def response_checker(response)
|
28
|
+
response_code = response.code.to_s
|
29
|
+
raise 'Not a valid response' unless %w[200 201].include? response_code
|
30
|
+
|
31
|
+
JSON.parse(response.body)
|
32
|
+
end
|
33
|
+
|
34
|
+
def submodule
|
35
|
+
raise 'This should be overriden'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'bci/base'
|
2
|
+
|
3
|
+
module Bci
|
4
|
+
# The class for BCI beneficios API
|
5
|
+
class Beneficios < Base
|
6
|
+
def submodule
|
7
|
+
'beneficios'
|
8
|
+
end
|
9
|
+
|
10
|
+
def shopping
|
11
|
+
local_url = "#{url}/descuentos-shopping"
|
12
|
+
response_checker(connector.get(local_url, headers))
|
13
|
+
rescue RestClient::InternalServerError => e
|
14
|
+
puts e
|
15
|
+
end
|
16
|
+
|
17
|
+
def store
|
18
|
+
local_url = "#{url}/productos-tienda"
|
19
|
+
response_checker(connector.get(local_url, headers))
|
20
|
+
rescue RestClient::InternalServerError => e
|
21
|
+
puts e
|
22
|
+
end
|
23
|
+
|
24
|
+
def health_and_beauty
|
25
|
+
local_url = "#{url}/descuentos-salud-belleza"
|
26
|
+
response_checker(connector.get(local_url, headers))
|
27
|
+
rescue RestClient::InternalServerError => e
|
28
|
+
puts e
|
29
|
+
end
|
30
|
+
|
31
|
+
def online_sales
|
32
|
+
local_url = "#{url}/descuentos-venta-online"
|
33
|
+
response_checker(connector.get(local_url, headers))
|
34
|
+
rescue RestClient::InternalServerError => e
|
35
|
+
puts e
|
36
|
+
end
|
37
|
+
|
38
|
+
def outdoors
|
39
|
+
local_url = "#{url}/descuentos-panoramas"
|
40
|
+
response_checker(connector.get(local_url, headers))
|
41
|
+
rescue RestClient::InternalServerError => e
|
42
|
+
puts e
|
43
|
+
end
|
44
|
+
|
45
|
+
def flavors
|
46
|
+
local_url = "#{url}/descuentos-sabores"
|
47
|
+
response_checker(connector.get(local_url, headers))
|
48
|
+
rescue RestClient::InternalServerError => e
|
49
|
+
puts e
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/bci/client.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Bci
|
2
|
+
# The class hub for all BCI APIs
|
3
|
+
class Client
|
4
|
+
def initialize(params)
|
5
|
+
api_key = params[:key]
|
6
|
+
|
7
|
+
@hipotecario = Bci::Hipotecario.new(api_key)
|
8
|
+
@consumo = Bci::Consumo.new(api_key)
|
9
|
+
@beneficios = Bci::Beneficios.new(api_key)
|
10
|
+
@stats = Bci::Stats.new(api_key)
|
11
|
+
end
|
12
|
+
|
13
|
+
def hipotecario
|
14
|
+
raise 'Client is undefined' unless @hipotecario
|
15
|
+
@hipotecario
|
16
|
+
end
|
17
|
+
|
18
|
+
def consumo
|
19
|
+
raise 'Client is undefined' unless @consumo
|
20
|
+
@consumo
|
21
|
+
end
|
22
|
+
|
23
|
+
def beneficios
|
24
|
+
raise 'Client is undefined' unless @beneficios
|
25
|
+
@beneficios
|
26
|
+
end
|
27
|
+
|
28
|
+
def stats
|
29
|
+
raise 'Client is undefined' unless @stats
|
30
|
+
@stats
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/bci/consumo.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bci/base'
|
2
|
+
|
3
|
+
module Bci
|
4
|
+
# The class for BCI consumo API
|
5
|
+
class Consumo < Base
|
6
|
+
def submodule
|
7
|
+
'creditos_consumo'
|
8
|
+
end
|
9
|
+
|
10
|
+
def simulate(params)
|
11
|
+
response_checker(connector.post(url, params.to_json, headers))
|
12
|
+
rescue RestClient::InternalServerError => e
|
13
|
+
puts e
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'bci/base'
|
2
|
+
|
3
|
+
module Bci
|
4
|
+
# The class for BCI hipotecario API
|
5
|
+
class Hipotecario < Base
|
6
|
+
def submodule
|
7
|
+
'creditos_hipotecarios'
|
8
|
+
end
|
9
|
+
|
10
|
+
def all
|
11
|
+
puts url
|
12
|
+
response_checker(connector.get(url, headers))
|
13
|
+
end
|
14
|
+
|
15
|
+
def find(id)
|
16
|
+
local_url = "#{url}/#{id}"
|
17
|
+
response_checker(connector.get(local_url, headers))
|
18
|
+
end
|
19
|
+
|
20
|
+
def simulate(id, params)
|
21
|
+
local_url = "#{url}/#{id}/simulaciones"
|
22
|
+
puts local_url
|
23
|
+
response_checker(connector.post(local_url, params.to_json, headers))
|
24
|
+
rescue RestClient::InternalServerError => e
|
25
|
+
puts e
|
26
|
+
end
|
27
|
+
|
28
|
+
def find_rates(id)
|
29
|
+
local_url = "#{url}/#{id}/tasas"
|
30
|
+
response_checker(connector.get(local_url, headers))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/bci/stats.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'bci/base'
|
2
|
+
|
3
|
+
module Bci
|
4
|
+
# The class for BCI indicadores API
|
5
|
+
class Stats < Base
|
6
|
+
def submodule
|
7
|
+
'info-banco'
|
8
|
+
end
|
9
|
+
|
10
|
+
def indicators
|
11
|
+
local_url = "#{url}/indicadores"
|
12
|
+
puts local_url
|
13
|
+
response_checker(connector.get(local_url, headers))
|
14
|
+
rescue RestClient::InternalServerError => e
|
15
|
+
puts e
|
16
|
+
end
|
17
|
+
|
18
|
+
def branch_offices
|
19
|
+
local_url = "#{url}/sucursales"
|
20
|
+
response_checker(connector.get(local_url, headers))
|
21
|
+
rescue RestClient::InternalServerError => e
|
22
|
+
puts e
|
23
|
+
end
|
24
|
+
|
25
|
+
def atm
|
26
|
+
local_url = "#{url}/cajeros"
|
27
|
+
response_checker(connector.get(local_url, headers))
|
28
|
+
rescue RestClient::InternalServerError => e
|
29
|
+
puts e
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/bci/version.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bci
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 17.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Ochoa John
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3'
|
27
|
+
description: A SDK to connect with BCI developers API
|
28
|
+
email:
|
29
|
+
- dochoajohn@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- bci.gemspec
|
40
|
+
- lib/bci.rb
|
41
|
+
- lib/bci/base.rb
|
42
|
+
- lib/bci/beneficios.rb
|
43
|
+
- lib/bci/client.rb
|
44
|
+
- lib/bci/consumo.rb
|
45
|
+
- lib/bci/hipotecario.rb
|
46
|
+
- lib/bci/stats.rb
|
47
|
+
- lib/bci/version.rb
|
48
|
+
- spec/spec_helper.rb
|
49
|
+
homepage: ''
|
50
|
+
licenses:
|
51
|
+
- Nonstandard
|
52
|
+
metadata: {}
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 2.6.11
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: A SDK to connect to BCI developers API
|
73
|
+
test_files:
|
74
|
+
- spec/spec_helper.rb
|