bipbop 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -4
- data/VERSION +1 -1
- data/bipbop.gemspec +4 -2
- data/lib/bipbop.rb +16 -3
- data/spec/bipbop_spec.rb +10 -2
- data/spec/fixtures/vcr_cassettes/bipbop/perfileconomico/invalid.yml +44 -0
- data/spec/fixtures/vcr_cassettes/bipbop/perfileconomico/valid-document.yml +53 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a8ec406ba88e0c7415e8bcfead6064cc52f0d1b
|
4
|
+
data.tar.gz: 2ede692611125adc0278418d1e6b6e9d2517b878
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 985c745f71f61b0a4e63be3bac5620546a57853226eb78bdb5151552c54a96564cac91f846ebdec81c1ac200b29f678c48f9adf85b8c06a1f880a796ec0db210
|
7
|
+
data.tar.gz: a3ab64458455c2f0d8469eba64b069ea109cf7e43d9b7e691a13aeffaa9e7f662e59a6bb18b75451bdf8631ee305dd266129ad8d5d612f27d11b2f0c92bb1657
|
data/README.md
CHANGED
@@ -42,10 +42,8 @@ bipbop.cpfcnpj(documento: '99999999000100') # where 99999999000100 is the number
|
|
42
42
|
bipbop = Bipbop.new('my api key')
|
43
43
|
bipbop.social(documento: '99999999999', email: 'user@example.com')
|
44
44
|
=> {
|
45
|
-
"name" =>
|
46
|
-
|
47
|
-
"gender" => "male"
|
48
|
-
},
|
45
|
+
"name" => "NAME OF PERSON",
|
46
|
+
"gender" => "male"
|
49
47
|
"approximate_age" => "30",
|
50
48
|
"hash" => "6CzXsZA09xMgXrHmJHUNY5X0cu7fv5yXwPGVX/i7nVE6awYftn5LpsVvdeoqbuMfBGdKIm0t1F+jrdifMraoyA==",
|
51
49
|
"criteria" => "A1",
|
@@ -58,6 +56,22 @@ bipbop.social(documento: '99999999999', email: 'user@example.com')
|
|
58
56
|
}
|
59
57
|
```
|
60
58
|
|
59
|
+
### PERFIL ECONÔMICO
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
bipbop = Bipbop.new('my api key')
|
63
|
+
bipbop.perfileconomico(documento: '99999999999')
|
64
|
+
=> {
|
65
|
+
"name" => "NAME OF PERSON",
|
66
|
+
"gender" => "male"
|
67
|
+
"approximate_age" => "30",
|
68
|
+
"hash" => "6CzXsZA09xMgXrHmJHUNY5X0cu7fv5yXwPGVX/i7nVE6awYftn5LpsVvdeoqbuMfBGdKIm0t1F+jrdifMraoyA==",
|
69
|
+
"criteria" => "A1",
|
70
|
+
"buy_limit" => "10214.87",
|
71
|
+
"buy_avg" => "268.33",
|
72
|
+
}
|
73
|
+
```
|
74
|
+
|
61
75
|
|
62
76
|
## LICENSE
|
63
77
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/bipbop.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: bipbop 0.
|
5
|
+
# stub: bipbop 0.5.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "bipbop"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.5.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -36,6 +36,8 @@ Gem::Specification.new do |s|
|
|
36
36
|
"spec/fixtures/vcr_cassettes/bipbop/cpfcnpj/invalid.yml",
|
37
37
|
"spec/fixtures/vcr_cassettes/bipbop/cpfcnpj/valid-cnpj.yml",
|
38
38
|
"spec/fixtures/vcr_cassettes/bipbop/cpfcnpj/valid-cpf.yml",
|
39
|
+
"spec/fixtures/vcr_cassettes/bipbop/perfileconomico/invalid.yml",
|
40
|
+
"spec/fixtures/vcr_cassettes/bipbop/perfileconomico/valid-document.yml",
|
39
41
|
"spec/fixtures/vcr_cassettes/bipbop/social/invalid.yml",
|
40
42
|
"spec/fixtures/vcr_cassettes/bipbop/social/valid-document-and-email.yml",
|
41
43
|
"spec/fixtures/vcr_cassettes/bipbop/social/valid-document.yml",
|
data/lib/bipbop.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'crack'
|
2
3
|
|
3
4
|
class Bipbop
|
4
5
|
include HTTParty
|
5
6
|
base_uri 'irql.bipbop.com.br'
|
6
7
|
|
8
|
+
parser(
|
9
|
+
Proc.new do |body, format|
|
10
|
+
Crack::XML.parse(body)
|
11
|
+
end
|
12
|
+
)
|
13
|
+
|
7
14
|
attr_reader :api_key
|
8
15
|
|
9
16
|
def initialize(api_key = nil)
|
@@ -15,7 +22,13 @@ class Bipbop
|
|
15
22
|
end
|
16
23
|
|
17
24
|
def social(params)
|
18
|
-
request(:social, :consulta, params)
|
25
|
+
response = request(:social, :consulta, params)
|
26
|
+
response.merge('gender' => response['name'].attributes['gender']) rescue response
|
27
|
+
end
|
28
|
+
|
29
|
+
def perfileconomico(params)
|
30
|
+
response = request(:ecommerce, :perfileconomico, params)
|
31
|
+
response.merge('gender' => response['name'].attributes['gender']) rescue response
|
19
32
|
end
|
20
33
|
|
21
34
|
private
|
@@ -29,8 +42,8 @@ class Bipbop
|
|
29
42
|
end
|
30
43
|
|
31
44
|
def request(database, table, params)
|
32
|
-
response = self.class.get("/", query(irql(database, table, params)))
|
33
|
-
(response.code == 200) ? response["IRQL"]['body'] : nil
|
45
|
+
@response = self.class.get("/", query(irql(database, table, params)))
|
46
|
+
(@response.code == 200) ? @response["IRQL"]['body'] : nil
|
34
47
|
end
|
35
48
|
|
36
49
|
def query(q)
|
data/spec/bipbop_spec.rb
CHANGED
@@ -30,10 +30,18 @@ describe "Bipbop" do
|
|
30
30
|
it { bipbop.social(documento: '9').should == {"influence"=>"20", "confidence"=>"42", "confidence_influence"=>"43", "confidence_criteria"=>"40"} }
|
31
31
|
end
|
32
32
|
context 'document', vcr: { cassette_name: 'bipbop/social/valid-document' } do
|
33
|
-
it { bipbop.social(documento: '09116059751').should == {"name"=>
|
33
|
+
it { bipbop.social(documento: '09116059751').should == {"name"=>"RAFAEL DE LIMA PAULA", "gender" => "male", "approximate_age"=>"30", "hash"=>"6CzXsZA09xMgXrHmJHUNY5X0cu7fv5yXwPGVX/i7nVE6awYftn5LpsVvdeoqbuMfBGdKIm0t1F+jrdifMraoyA==", "criteria"=>"A1", "buy_limit"=>"10214.87", "buy_avg"=>"268.33", "influence"=>"52", "confidence"=>"57", "confidence_influence"=>"56", "confidence_criteria"=>"59"} }
|
34
34
|
end
|
35
35
|
context 'document with email', vcr: { cassette_name: 'bipbop/social/valid-document-and-email' } do
|
36
|
-
it { bipbop.social(documento: '09116059751', email: 'contato@rafael.adm.br').should == {"name"=>
|
36
|
+
it { bipbop.social(documento: '09116059751', email: 'contato@rafael.adm.br').should == {"name"=>"RAFAEL DE LIMA PAULA", "gender" => "male", "approximate_age"=>"30", "hash"=>"D9C1OOc/DF5kubLGgKxSDlGL3owYz9+eZx/Wz423G3U5lj+ZqfZF7fv3f2m4GNEHSkwFpEFuaX90fCB4Vug8EA==", "criteria"=>"A1", "buy_limit"=>"10214.87", "buy_avg"=>"268.33", "influence"=>"52", "confidence"=>"57", "confidence_influence"=>"56", "confidence_criteria"=>"59"} }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
describe 'perfileconomico' do
|
40
|
+
context 'invalid', vcr: { cassette_name: 'bipbop/perfileconomico/invalid' } do
|
41
|
+
it { bipbop.perfileconomico(documento: '9').should be_nil }
|
42
|
+
end
|
43
|
+
context 'document', vcr: { cassette_name: 'bipbop/perfileconomico/valid-document' } do
|
44
|
+
it { bipbop.perfileconomico(documento: '09116059751').should == {"name"=>"RAFAEL DE LIMA PAULA", "gender" => "male", "approximate_age"=>"30", "hash"=>"6CzXsZA09xMgXrHmJHUNY5X0cu7fv5yXwPGVX/i7nVE6awYftn5LpsVvdeoqbuMfBGdKIm0t1F+jrdifMraoyA==", "criteria"=>"A1", "buy_limit"=>"10214.87", "buy_avg"=>"268.33"} }
|
37
45
|
end
|
38
46
|
end
|
39
47
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://irql.bipbop.com.br/?apiKey=BIPBOP_API_KEY&q=SELECT%20FROM%20'ECOMMERCE'.'PERFILECONOMICO'%20WHERE%20'DOCUMENTO'%20=%20'9'
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 500
|
13
|
+
message: Internal Server Error
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- no-cache="set-cookie"
|
17
|
+
- public
|
18
|
+
Content-Type:
|
19
|
+
- text/xml
|
20
|
+
Date:
|
21
|
+
- Fri, 03 Oct 2014 03:52:04 GMT
|
22
|
+
Expires:
|
23
|
+
- Sat, 04 Oct 2014 03:52:04 GMT
|
24
|
+
Server:
|
25
|
+
- bipbop
|
26
|
+
Set-Cookie:
|
27
|
+
- AWSELB=AB014DFB0639528854AECF5F443FF4231F941D34070C60DB9436CE39A70DE73B27E54CADAE64AEB083A406D8BC20545C7EF0A812122A8B2F9155C493CB14894B2CE2B49520;PATH=/;MAX-AGE=86400
|
28
|
+
Content-Length:
|
29
|
+
- '286'
|
30
|
+
Connection:
|
31
|
+
- keep-alive
|
32
|
+
body:
|
33
|
+
encoding: ASCII-8BIT
|
34
|
+
string: !binary |-
|
35
|
+
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPElSUUw+
|
36
|
+
CiAgPGhlYWRlcj4KICAgIDxkZXNjcmlwdGlvbj5JbnRlcm5hbCBTZXJ2ZXIg
|
37
|
+
RXJyb3I8L2Rlc2NyaXB0aW9uPgogICAgPGRhdGUtdGltZT4wMy8xMC8yMDE0
|
38
|
+
IDAwOjUyOjA0PC9kYXRlLXRpbWU+CiAgICA8ZXhjZXB0aW9uIGNvZGU9IjAi
|
39
|
+
IHNvdXJjZT0iRXhjZXB0aW9uRGF0YWJhc2UiPk8gZG9jdW1lbnRvIG7Do28g
|
40
|
+
cGFyZWNlIHNlciB2w6FsaWRvPC9leGNlcHRpb24+CiAgPC9oZWFkZXI+CiAg
|
41
|
+
PGJvZHkvPgo8L0lSUUw+Cg==
|
42
|
+
http_version:
|
43
|
+
recorded_at: Fri, 03 Oct 2014 03:52:00 GMT
|
44
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,53 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://irql.bipbop.com.br/?apiKey=BIPBOP_API_KEY&q=SELECT%20FROM%20'ECOMMERCE'.'PERFILECONOMICO'%20WHERE%20'DOCUMENTO'%20=%20'09116059751'
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- no-cache="set-cookie"
|
17
|
+
- public
|
18
|
+
Content-Type:
|
19
|
+
- text/xml
|
20
|
+
Date:
|
21
|
+
- Fri, 03 Oct 2014 03:52:04 GMT
|
22
|
+
Expires:
|
23
|
+
- Sat, 04 Oct 2014 03:52:04 GMT
|
24
|
+
Server:
|
25
|
+
- bipbop
|
26
|
+
Set-Cookie:
|
27
|
+
- AWSELB=AB014DFB0639528854AECF5F443FF4231F941D34070C60DB9436CE39A70DE73B27E54CADAE64AEB083A406D8BC20545C7EF0A812122A8B2F9155C493CB14894B2CE2B49520;PATH=/;MAX-AGE=86400
|
28
|
+
Content-Length:
|
29
|
+
- '690'
|
30
|
+
Connection:
|
31
|
+
- keep-alive
|
32
|
+
body:
|
33
|
+
encoding: ASCII-8BIT
|
34
|
+
string: !binary |-
|
35
|
+
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPElSUUw+
|
36
|
+
CiAgPGhlYWRlcj4KICAgIDxkZXNjcmlwdGlvbj5DbGFzc2lmaWNhw6fDo28g
|
37
|
+
RWNvbsO0bWljYSBwYXJhIGUtQ29tbWVyY2U8L2Rlc2NyaXB0aW9uPgogICAg
|
38
|
+
PGRhdGUtdGltZT4wMy8xMC8yMDE0IDAwOjUyOjA0PC9kYXRlLXRpbWU+CiAg
|
39
|
+
ICA8ZXhlY3V0aW9uLXRpbWU+MDwvZXhlY3V0aW9uLXRpbWU+CiAgICA8cXVl
|
40
|
+
cnkgZGF0YWJhc2U9IkVDT01NRVJDRSIgdGFibGU9IlBFUkZJTEVDT05PTUlD
|
41
|
+
TyI+U0VMRUNUIEZST00gJ0VDT01NRVJDRScuJ1BFUkZJTEVDT05PTUlDTycg
|
42
|
+
V0hFUkUgJ0RPQ1VNRU5UTycgPSAnMDkxMTYwNTk3NTEnPC9xdWVyeT4KICA8
|
43
|
+
L2hlYWRlcj4KICA8Ym9keT4KICAgIDxuYW1lIGdlbmRlcj0ibWFsZSI+UkFG
|
44
|
+
QUVMIERFIExJTUEgUEFVTEE8L25hbWU+CiAgICA8YXBwcm94aW1hdGUtYWdl
|
45
|
+
PjMwPC9hcHByb3hpbWF0ZS1hZ2U+CiAgICA8aGFzaD42Q3pYc1pBMDl4TWdY
|
46
|
+
ckhtSkhVTlk1WDBjdTdmdjV5WHdQR1ZYL2k3blZFNmF3WWZ0bjVMcHNWdmRl
|
47
|
+
b3FidU1mQkdkS0ltMHQxRitqcmRpZk1yYW95QT09PC9oYXNoPgogICAgPGNy
|
48
|
+
aXRlcmlhPkExPC9jcml0ZXJpYT4KICAgIDxidXktbGltaXQ+MTAyMTQuODc8
|
49
|
+
L2J1eS1saW1pdD4KICAgIDxidXktYXZnPjI2OC4zMzwvYnV5LWF2Zz4KICA8
|
50
|
+
L2JvZHk+CjwvSVJRTD4K
|
51
|
+
http_version:
|
52
|
+
recorded_at: Fri, 03 Oct 2014 03:52:01 GMT
|
53
|
+
recorded_with: VCR 2.9.3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bipbop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Lima
|
@@ -190,6 +190,8 @@ files:
|
|
190
190
|
- spec/fixtures/vcr_cassettes/bipbop/cpfcnpj/invalid.yml
|
191
191
|
- spec/fixtures/vcr_cassettes/bipbop/cpfcnpj/valid-cnpj.yml
|
192
192
|
- spec/fixtures/vcr_cassettes/bipbop/cpfcnpj/valid-cpf.yml
|
193
|
+
- spec/fixtures/vcr_cassettes/bipbop/perfileconomico/invalid.yml
|
194
|
+
- spec/fixtures/vcr_cassettes/bipbop/perfileconomico/valid-document.yml
|
193
195
|
- spec/fixtures/vcr_cassettes/bipbop/social/invalid.yml
|
194
196
|
- spec/fixtures/vcr_cassettes/bipbop/social/valid-document-and-email.yml
|
195
197
|
- spec/fixtures/vcr_cassettes/bipbop/social/valid-document.yml
|