blockscore 2.0.1 → 2.1.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 +1 -1
- data/VERSION +1 -1
- data/blockscore.gemspec +4 -3
- data/lib/blockscore/client.rb +2 -5
- data/lib/blockscore/company.rb +35 -0
- data/lib/blockscore/error/blockscore_error.rb +3 -2
- data/lib/blockscore/question_set.rb +9 -17
- data/lib/blockscore/verification.rb +0 -10
- data/test/test_blockscore.rb +77 -28
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e7e9be7f4741751bb2d8f05439f2f955eb4f666
|
4
|
+
data.tar.gz: 20939949826f3f40d4cb81a325819e326818e597
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c41056637f672fed83e96a7960348fb2152b4b850277d6c6a4f39c8c154c588c1f1ce755b479e21a2762c5f0dc9d7cef93d8d741cd890bd3875ae6be0cbe2a4e
|
7
|
+
data.tar.gz: 67315cbc4dbdd5f3c234b59987782a70a43ed8dba10202a7cffc4110aefcef6f784e384c46bc13dc345ac5fc74f02ee7a1fd85666ea71304edf2f7ce2a5b23d7
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0
|
data/blockscore.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
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: blockscore 2.0
|
5
|
+
# stub: blockscore 2.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "blockscore"
|
9
|
-
s.version = "2.0
|
9
|
+
s.version = "2.1.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"]
|
13
13
|
s.authors = ["Alain Meier"]
|
14
|
-
s.date = "2014-06-
|
14
|
+
s.date = "2014-06-30"
|
15
15
|
s.description = "A ruby client library for the BlockScore API."
|
16
16
|
s.email = "alain@blockscore.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/blockscore-cert.crt",
|
32
32
|
"lib/blockscore.rb",
|
33
33
|
"lib/blockscore/client.rb",
|
34
|
+
"lib/blockscore/company.rb",
|
34
35
|
"lib/blockscore/error/authorization_error.rb",
|
35
36
|
"lib/blockscore/error/blockscore_error.rb",
|
36
37
|
"lib/blockscore/error/error_handler.rb",
|
data/lib/blockscore/client.rb
CHANGED
@@ -5,15 +5,14 @@ module BlockScore
|
|
5
5
|
@ssl_path = File.expand_path(File.join(File.dirname(__FILE__), '../blockscore-cert.crt'))
|
6
6
|
ssl_ca_file @ssl_path
|
7
7
|
|
8
|
-
attr_reader :verification
|
9
|
-
attr_reader :question_set
|
8
|
+
attr_reader :verification, :question_set, :company
|
10
9
|
|
11
10
|
def initialize(api_key, version, options = {})
|
12
|
-
|
13
11
|
@api_key = api_key
|
14
12
|
@auth = { :username => @api_key, :password => "" }
|
15
13
|
@verification = BlockScore::Verification.new(self)
|
16
14
|
@question_set = BlockScore::QuestionSet.new(self)
|
15
|
+
@company = BlockScore::Company.new(self)
|
17
16
|
@error_handler = BlockScore::ErrorHandler.new
|
18
17
|
|
19
18
|
options[:base_uri] ||= "https://api.blockscore.com"
|
@@ -25,7 +24,6 @@ module BlockScore
|
|
25
24
|
end
|
26
25
|
|
27
26
|
def get(path, options = {})
|
28
|
-
|
29
27
|
options = { :body => options, :basic_auth => @auth }
|
30
28
|
|
31
29
|
response = self.class.get(path, options)
|
@@ -39,7 +37,6 @@ module BlockScore
|
|
39
37
|
end
|
40
38
|
|
41
39
|
def post(path, options = {})
|
42
|
-
|
43
40
|
options = { :body => options, :basic_auth => @auth }
|
44
41
|
|
45
42
|
response = self.class.post(path, options)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module BlockScore
|
2
|
+
class Company
|
3
|
+
|
4
|
+
def initialize(client)
|
5
|
+
@client = client
|
6
|
+
end
|
7
|
+
|
8
|
+
#
|
9
|
+
# /companies POST
|
10
|
+
#
|
11
|
+
def create(options = {})
|
12
|
+
response = @client.post '/companies', options
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# /companies/:id GET
|
17
|
+
#
|
18
|
+
def retrieve(id, options = {})
|
19
|
+
body = (options.include? :query) ? options[:body] : {}
|
20
|
+
response = @client.get "/companies/#{id.to_s}", body
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# '/companies' GET
|
25
|
+
#
|
26
|
+
def all(count = nil, offset = nil, options = {})
|
27
|
+
body = (options.include? :body) ? options[:body] : {}
|
28
|
+
|
29
|
+
body[:count] = count
|
30
|
+
body[:offset] = offset
|
31
|
+
|
32
|
+
@client.get '/companies', body
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -10,11 +10,12 @@ module BlockScore
|
|
10
10
|
error_type="invalid_request_error")
|
11
11
|
super(message)
|
12
12
|
|
13
|
-
|
13
|
+
message_desc = "#{json_body["error"]["param"]} #{json_body["error"]["code"]}"
|
14
|
+
|
14
15
|
@error_type = error_type
|
15
16
|
@http_status = http_status
|
16
17
|
@json_body = json_body
|
17
|
-
|
18
|
+
@message = "#{message} (#{message_desc})"
|
18
19
|
end
|
19
20
|
|
20
21
|
def to_s
|
@@ -13,39 +13,31 @@ module BlockScore
|
|
13
13
|
end
|
14
14
|
|
15
15
|
#
|
16
|
-
# '/questions/score' POST
|
16
|
+
# '/questions/:id/score' POST
|
17
17
|
#
|
18
|
-
# verification_id -
|
19
|
-
# question_set_id -
|
20
18
|
# answers -
|
21
|
-
def score(
|
22
|
-
|
23
|
-
body =
|
24
|
-
|
25
|
-
|
26
|
-
:answers => answers
|
27
|
-
}
|
28
|
-
|
29
|
-
response = @client.post "/questions/score", body
|
19
|
+
def score(id, answers)
|
20
|
+
body = {}
|
21
|
+
body[:answers] = answers
|
22
|
+
|
23
|
+
response = @client.post "/questions/#{id.to_s}/score", body
|
30
24
|
end
|
31
25
|
|
32
26
|
#
|
33
|
-
# /questions/:id
|
27
|
+
# /questions/:id GET
|
34
28
|
#
|
35
29
|
# question_set_id -
|
36
30
|
# verification_id -
|
37
|
-
def retrieve(
|
31
|
+
def retrieve(id)
|
38
32
|
body = Hash.new
|
39
|
-
body[:verification_id] = verification_id
|
40
33
|
|
41
|
-
response = @client.
|
34
|
+
response = @client.get "/questions/#{id.to_s}", body
|
42
35
|
end
|
43
36
|
|
44
37
|
#
|
45
38
|
# '/questions' GET
|
46
39
|
#
|
47
40
|
def all(count = nil, offset = nil, options = {})
|
48
|
-
|
49
41
|
body = (options.include? :body) ? options[:body] : {}
|
50
42
|
|
51
43
|
body[:count] = count
|
@@ -2,18 +2,12 @@ module BlockScore
|
|
2
2
|
class Verification
|
3
3
|
|
4
4
|
def initialize(client)
|
5
|
-
|
6
5
|
@client = client
|
7
6
|
end
|
8
7
|
|
9
8
|
#
|
10
9
|
# /verifications POST
|
11
10
|
#
|
12
|
-
# type -
|
13
|
-
# date_of_birth -
|
14
|
-
# identification -
|
15
|
-
# name -
|
16
|
-
# address -
|
17
11
|
def create(options = {})
|
18
12
|
response = @client.post '/verifications', options
|
19
13
|
end
|
@@ -23,10 +17,7 @@ module BlockScore
|
|
23
17
|
#
|
24
18
|
# id -
|
25
19
|
def retrieve(id, options = {})
|
26
|
-
|
27
20
|
body = (options.include? :query) ? options[:body] : {}
|
28
|
-
body[:verification_id] = id
|
29
|
-
|
30
21
|
response = @client.get "/verifications/#{id.to_s}", body
|
31
22
|
end
|
32
23
|
|
@@ -34,7 +25,6 @@ module BlockScore
|
|
34
25
|
# '/verifications' GET
|
35
26
|
#
|
36
27
|
def all(count = nil, offset = nil, options = {})
|
37
|
-
|
38
28
|
body = (options.include? :body) ? options[:body] : {}
|
39
29
|
|
40
30
|
body[:count] = count
|
data/test/test_blockscore.rb
CHANGED
@@ -1,39 +1,90 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'helper')
|
2
2
|
|
3
3
|
class TestBlockScore < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
# If you'd like to run the test suite, fill in your API key,
|
5
|
+
# a verification ID and a question set ID below.
|
6
|
+
@version = 3
|
7
|
+
@api_key = ""
|
8
|
+
|
9
|
+
@@verification_id = ""
|
10
|
+
@@question_set_id = ""
|
11
|
+
@@company_id = ""
|
12
|
+
@@client = BlockScore::Client.new(@api_key, version = @version)
|
13
|
+
|
14
|
+
context "a company" do
|
15
|
+
should "return a list of companies" do
|
16
|
+
response = @@client.company.all
|
17
|
+
assert_equal 200, response.code
|
18
|
+
end
|
19
|
+
|
20
|
+
should "return count = 2 companies" do
|
21
|
+
response = @@client.company.all(count = 2)
|
22
|
+
assert_equal 200, response.code
|
23
|
+
end
|
24
|
+
|
25
|
+
should "return count=2 offset=2 companies" do
|
26
|
+
response = @@client.company.all(count = 2, offset = 2)
|
27
|
+
assert_equal 200, response.code
|
28
|
+
end
|
29
|
+
|
30
|
+
should "return a single company" do
|
31
|
+
response = @@client.company.retrieve(@@company_id)
|
32
|
+
assert_equal 200, response.code
|
33
|
+
end
|
34
|
+
|
35
|
+
should "return create a company" do
|
36
|
+
company_params = {
|
37
|
+
:entity_name => "BlockScore",
|
38
|
+
:tax_id => "123410000",
|
39
|
+
:incorp_date => "1980-08-25",
|
40
|
+
:incorp_state => "DE",
|
41
|
+
:incorp_country_code => "US",
|
42
|
+
:incorp_type => "corporation",
|
43
|
+
:dbas => "BitRemit",
|
44
|
+
:registration_number => "123123123",
|
45
|
+
:email => "test@example.com",
|
46
|
+
:url => "https://blockscore.com",
|
47
|
+
:phone_number => "6505555555",
|
48
|
+
:ip_address => "67.160.8.182",
|
49
|
+
:address => {
|
50
|
+
:street1 => "1 Infinite Loop",
|
51
|
+
:street2 => nil,
|
52
|
+
:city => "Cupertino",
|
53
|
+
:state => "CA",
|
54
|
+
:postal_code => "95014",
|
55
|
+
:country_code => "US"
|
56
|
+
}
|
57
|
+
}
|
9
58
|
|
10
|
-
|
11
|
-
|
59
|
+
response = @@client.company.create(company_params)
|
60
|
+
|
61
|
+
assert_equal 201, response.code
|
12
62
|
end
|
63
|
+
end
|
13
64
|
|
65
|
+
context "a verification" do
|
14
66
|
should "return a list of verifications" do
|
15
|
-
response =
|
67
|
+
response = @@client.verification.all
|
16
68
|
assert_equal 200, response.code
|
17
69
|
end
|
18
70
|
|
19
71
|
should "return count = 2 verifications" do
|
20
|
-
response =
|
72
|
+
response = @@client.verification.all(count = 2)
|
21
73
|
assert_equal 200, response.code
|
22
74
|
end
|
23
75
|
|
24
76
|
should "return count=2 offset=2 verifications" do
|
25
|
-
response =
|
77
|
+
response = @@client.verification.all(count = 2, offset = 2)
|
26
78
|
assert_equal 200, response.code
|
27
79
|
end
|
28
80
|
|
29
81
|
should "return a single verification" do
|
30
|
-
response =
|
82
|
+
response = @@client.verification.retrieve(@@verification_id)
|
31
83
|
assert_equal 200, response.code
|
32
84
|
end
|
33
85
|
|
34
86
|
should "return create a verification" do
|
35
87
|
verification_params = {
|
36
|
-
:type => "us_citizen",
|
37
88
|
:date_of_birth => "1975-01-01",
|
38
89
|
:identification => {
|
39
90
|
:ssn => "0000"
|
@@ -49,41 +100,43 @@ class TestBlockScore < Test::Unit::TestCase
|
|
49
100
|
:city => "Cupertino",
|
50
101
|
:state => "CA",
|
51
102
|
:postal_code => "95014",
|
52
|
-
:
|
103
|
+
:country_code => "US"
|
53
104
|
}
|
54
105
|
}
|
55
106
|
|
56
|
-
response =
|
107
|
+
response = @@client.verification.create(verification_params)
|
57
108
|
|
58
109
|
assert_equal 201, response.code
|
59
110
|
end
|
111
|
+
end
|
60
112
|
|
113
|
+
context "a question set" do
|
61
114
|
should "return create a question set" do
|
62
|
-
response =
|
115
|
+
response = @@client.question_set.create(@@verification_id)
|
63
116
|
assert_equal 201, response.code
|
64
117
|
end
|
65
118
|
|
66
119
|
should "return a single question set" do
|
67
|
-
response =
|
68
|
-
assert_equal
|
120
|
+
response = @@client.question_set.retrieve(@@question_set_id)
|
121
|
+
assert_equal 200, response.code
|
69
122
|
end
|
70
123
|
|
71
124
|
should "return a list of question sets" do
|
72
|
-
response =
|
125
|
+
response = @@client.question_set.all
|
73
126
|
assert_equal 200, response.code
|
74
127
|
end
|
75
128
|
|
76
|
-
should "return count = 2
|
77
|
-
response =
|
129
|
+
should "return count = 2" do
|
130
|
+
response = @@client.question_set.all(count = 2)
|
78
131
|
assert_equal 200, response.code
|
79
132
|
end
|
80
133
|
|
81
|
-
should "return count = 2 offset = 2
|
82
|
-
response =
|
134
|
+
should "return count = 2 offset = 2" do
|
135
|
+
response = @@client.question_set.all(count = 2, offset = 2)
|
83
136
|
assert_equal 200, response.code
|
84
137
|
end
|
85
138
|
|
86
|
-
should "return a score
|
139
|
+
should "return a score" do
|
87
140
|
@answers = [
|
88
141
|
{
|
89
142
|
:question_id => 1,
|
@@ -107,11 +160,7 @@ class TestBlockScore < Test::Unit::TestCase
|
|
107
160
|
}
|
108
161
|
]
|
109
162
|
|
110
|
-
response =
|
111
|
-
@verification_id,
|
112
|
-
@question_set_id,
|
113
|
-
@answers
|
114
|
-
)
|
163
|
+
response = @@client.question_set.score(@@question_set_id, @answers)
|
115
164
|
|
116
165
|
assert_equal 201, response.code
|
117
166
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blockscore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alain Meier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/blockscore-cert.crt
|
143
143
|
- lib/blockscore.rb
|
144
144
|
- lib/blockscore/client.rb
|
145
|
+
- lib/blockscore/company.rb
|
145
146
|
- lib/blockscore/error/authorization_error.rb
|
146
147
|
- lib/blockscore/error/blockscore_error.rb
|
147
148
|
- lib/blockscore/error/error_handler.rb
|