blockscore 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +58 -0
- data/.hound.yml +217 -0
- data/Gemfile +19 -7
- data/LICENSE +21 -0
- data/README.md +37 -33
- data/Rakefile +1 -15
- data/blockscore.gemspec +30 -81
- data/circle.yml +13 -0
- data/lib/blockscore.rb +43 -4
- data/lib/blockscore/actions/all.rb +27 -0
- data/lib/blockscore/actions/create.rb +34 -0
- data/lib/blockscore/actions/delete.rb +31 -0
- data/lib/blockscore/actions/retrieve.rb +24 -0
- data/lib/blockscore/actions/update.rb +46 -0
- data/lib/blockscore/base.rb +117 -0
- data/lib/blockscore/candidate.rb +32 -0
- data/lib/blockscore/collection.rb +12 -0
- data/lib/blockscore/company.rb +7 -0
- data/lib/blockscore/connection.rb +65 -0
- data/lib/blockscore/dispatch.rb +26 -0
- data/lib/blockscore/errors/api_connection_error.rb +6 -0
- data/lib/blockscore/errors/api_error.rb +33 -0
- data/lib/blockscore/errors/authentication_error.rb +4 -0
- data/lib/blockscore/errors/error.rb +4 -0
- data/lib/blockscore/errors/invalid_request_error.rb +29 -0
- data/lib/blockscore/errors/no_api_key_error.rb +4 -0
- data/lib/blockscore/errors/not_found_error.rb +4 -0
- data/lib/blockscore/fingerprint.rb +46 -0
- data/lib/blockscore/person.rb +14 -0
- data/lib/blockscore/question_set.rb +26 -0
- data/lib/blockscore/response.rb +29 -0
- data/lib/blockscore/util.rb +80 -0
- data/lib/blockscore/version.rb +3 -0
- data/lib/blockscore/watchlist_hit.rb +4 -0
- metadata +82 -48
- data/LICENSE.txt +0 -20
- data/VERSION +0 -1
- data/blockscore-ruby.sublime-project +0 -21
- data/lib/blockscore/candidates.rb +0 -49
- data/lib/blockscore/client.rb +0 -81
- data/lib/blockscore/companies.rb +0 -36
- data/lib/blockscore/error/authorization_error.rb +0 -13
- data/lib/blockscore/error/blockscore_error.rb +0 -26
- data/lib/blockscore/error/error_handler.rb +0 -141
- data/lib/blockscore/error/internal_server_error.rb +0 -19
- data/lib/blockscore/error/not_found_error.rb +0 -12
- data/lib/blockscore/error/parameter_error.rb +0 -12
- data/lib/blockscore/error/validation_error.rb +0 -28
- data/lib/blockscore/errors.rb +0 -3
- data/lib/blockscore/people.rb +0 -37
- data/lib/blockscore/question_sets.rb +0 -49
- data/lib/blockscore/watchlists.rb +0 -18
- data/test/helper.rb +0 -37
- data/test/test_blockscore.rb +0 -226
@@ -1,13 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'blockscore_error')
|
2
|
-
|
3
|
-
module BlockScore
|
4
|
-
class AuthorizationError < BlockscoreError
|
5
|
-
|
6
|
-
@@http_status = 401
|
7
|
-
|
8
|
-
def initialize(message=nil, json_body=nil, error_type=nil)
|
9
|
-
|
10
|
-
super(message, json_body, @@http_status, error_type)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module BlockScore
|
2
|
-
class BlockscoreError < StandardError
|
3
|
-
|
4
|
-
attr_reader :message
|
5
|
-
attr_reader :error_type
|
6
|
-
attr_reader :http_status
|
7
|
-
attr_reader :json_body
|
8
|
-
|
9
|
-
def initialize(message=nil, json_body=nil, http_status="400",
|
10
|
-
error_type="invalid_request_error")
|
11
|
-
super(message)
|
12
|
-
|
13
|
-
message_desc = "#{json_body["error"]["param"]} #{json_body["error"]["code"]}"
|
14
|
-
|
15
|
-
@error_type = error_type
|
16
|
-
@http_status = http_status
|
17
|
-
@json_body = json_body
|
18
|
-
@message = "#{message} (#{message_desc})"
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_s
|
22
|
-
"Status: #{@http_status}. Type: #{@error_type}, Message: #{@message}"
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
@@ -1,141 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
module BlockScore
|
3
|
-
class ErrorHandler
|
4
|
-
|
5
|
-
def initialize()
|
6
|
-
end
|
7
|
-
|
8
|
-
# Function:
|
9
|
-
# check_error()
|
10
|
-
#
|
11
|
-
# response -
|
12
|
-
#
|
13
|
-
def check_error(response)
|
14
|
-
|
15
|
-
@code = response.code
|
16
|
-
@type = response.headers['content-type']
|
17
|
-
|
18
|
-
if (200 <= @code and @code < 300)
|
19
|
-
return response
|
20
|
-
end
|
21
|
-
|
22
|
-
@body = get_body(response)
|
23
|
-
@message = get_message(@body)
|
24
|
-
@error_type = @error_code = @param = nil
|
25
|
-
|
26
|
-
# Internal API Error
|
27
|
-
if @code == 500
|
28
|
-
raise BlockScore::InternalServerError.new(@message, @body, @error_type)
|
29
|
-
end
|
30
|
-
|
31
|
-
if @body.include? 'error'
|
32
|
-
@error = @body['error']
|
33
|
-
@error_type = get_value(@error, 'type')
|
34
|
-
@error_code = get_value(@error, 'code')
|
35
|
-
@param = get_value(@error, 'param')
|
36
|
-
end # body.include? 'error'
|
37
|
-
|
38
|
-
process_code(@code)
|
39
|
-
|
40
|
-
end # check_error
|
41
|
-
|
42
|
-
|
43
|
-
# Function:
|
44
|
-
# process_code()
|
45
|
-
#
|
46
|
-
# Tries to determine which error to raise.
|
47
|
-
#
|
48
|
-
# code -
|
49
|
-
#
|
50
|
-
def process_code(code)
|
51
|
-
|
52
|
-
# Input data error
|
53
|
-
if code == 400
|
54
|
-
# Could not be validated.
|
55
|
-
# Which type of input error?
|
56
|
-
if @param
|
57
|
-
raise BlockScore::ValidationError.new(@message, @body, @error_type, @param, @error_code)
|
58
|
-
|
59
|
-
# Required parameter is missing
|
60
|
-
else
|
61
|
-
raise BlockScore::ParameterError.new(@message, @body, @error_type)
|
62
|
-
end # if param
|
63
|
-
|
64
|
-
# Error with an API Key
|
65
|
-
elsif code == 401
|
66
|
-
raise BlockScore::AuthorizationError.new(@message, @body, @error_type)
|
67
|
-
|
68
|
-
# Trying to access nonexistent endpoint
|
69
|
-
elsif code == 404
|
70
|
-
raise BlockScore::NotFoundError.new(@message, @body, @error_type)
|
71
|
-
|
72
|
-
# Generic BlockscoreError (fallback)
|
73
|
-
else
|
74
|
-
raise BlockScore::BlockscoreError.new(@message, @body)
|
75
|
-
|
76
|
-
end # end code checking
|
77
|
-
|
78
|
-
end # process code
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
# Function:
|
83
|
-
# get_body()
|
84
|
-
#
|
85
|
-
# response -
|
86
|
-
#
|
87
|
-
def get_body(response)
|
88
|
-
type = response.headers['content-type']
|
89
|
-
body = response.body
|
90
|
-
|
91
|
-
# If response body is in JSON
|
92
|
-
if type.include? 'json'
|
93
|
-
body = JSON.parse(body)
|
94
|
-
end # type.include?
|
95
|
-
|
96
|
-
body
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
# Function:
|
102
|
-
# get_message()
|
103
|
-
#
|
104
|
-
# body -
|
105
|
-
#
|
106
|
-
def get_message(body)
|
107
|
-
message = ''
|
108
|
-
if body.is_a? String
|
109
|
-
message = body
|
110
|
-
|
111
|
-
elsif body.is_a? Hash
|
112
|
-
if body.include? 'error'
|
113
|
-
message = body['error']['message']
|
114
|
-
else
|
115
|
-
message = 'Unable to select error message from json returned by request responsible for error'
|
116
|
-
end # if body.include?
|
117
|
-
else
|
118
|
-
message = 'Unable to understand the content type of response returned by request responsible for error'
|
119
|
-
end # if body.is_a? String
|
120
|
-
|
121
|
-
message
|
122
|
-
end # def get_message
|
123
|
-
|
124
|
-
|
125
|
-
# Function:
|
126
|
-
# get_value()
|
127
|
-
#
|
128
|
-
# obj -
|
129
|
-
# key -
|
130
|
-
#
|
131
|
-
def get_value(obj, key)
|
132
|
-
|
133
|
-
if obj.include? key
|
134
|
-
return obj[key]
|
135
|
-
end
|
136
|
-
|
137
|
-
nil
|
138
|
-
end
|
139
|
-
|
140
|
-
end # class ErrorHandler
|
141
|
-
end # module BlockScore
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'blockscore_error')
|
2
|
-
|
3
|
-
module BlockScore
|
4
|
-
class InternalServerError < BlockscoreError
|
5
|
-
|
6
|
-
@@http_status = 500
|
7
|
-
|
8
|
-
def initialize(message=nil, json_body=nil, error_type=nil)
|
9
|
-
|
10
|
-
super(message, json_body, @@http_status, error_type)
|
11
|
-
|
12
|
-
@message = message
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_s
|
16
|
-
"Status: #{@@http_status}, Message: #{@message}"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'blockscore_error')
|
2
|
-
|
3
|
-
module BlockScore
|
4
|
-
class NotFoundError < BlockscoreError
|
5
|
-
|
6
|
-
@@http_status = 404
|
7
|
-
|
8
|
-
def initialize(message=nil, json_body=nil, error_type=nil)
|
9
|
-
super(message, json_body, @@http_status, error_type)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'blockscore_error')
|
2
|
-
|
3
|
-
module BlockScore
|
4
|
-
class ParameterError < BlockscoreError
|
5
|
-
|
6
|
-
@@http_status = 400
|
7
|
-
|
8
|
-
def initialize(message=nil, json_body=nil, error_type=nil)
|
9
|
-
super(message, json_body, @@http_status, error_type)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'blockscore_error')
|
2
|
-
|
3
|
-
module BlockScore
|
4
|
-
class ValidationError < BlockscoreError
|
5
|
-
|
6
|
-
attr_reader :http_status
|
7
|
-
attr_reader :error_code
|
8
|
-
attr_reader :param
|
9
|
-
|
10
|
-
@@http_status = 400
|
11
|
-
|
12
|
-
def initialize(message=nil, json_body=nil,
|
13
|
-
error_type=nil, param=nil, error_code=nil)
|
14
|
-
|
15
|
-
super(message, json_body, @@http_status, error_type)
|
16
|
-
|
17
|
-
@error_code = error_code
|
18
|
-
@param = param
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def to_s
|
23
|
-
s = "Status: #{@@http_status}, Type: #{@error_type}, Param: #{@param}, "
|
24
|
-
s += "Code: #{@error_code}, Message: #{@message}"
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
data/lib/blockscore/errors.rb
DELETED
data/lib/blockscore/people.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module BlockScore
|
2
|
-
class People
|
3
|
-
PATH = '/people'
|
4
|
-
|
5
|
-
def initialize(client)
|
6
|
-
@client = client
|
7
|
-
end
|
8
|
-
|
9
|
-
#
|
10
|
-
# /people POST
|
11
|
-
#
|
12
|
-
def create(options = {})
|
13
|
-
response = @client.post PATH, options
|
14
|
-
end
|
15
|
-
|
16
|
-
#
|
17
|
-
# /people/:id GET
|
18
|
-
#
|
19
|
-
# id - ID of the person to retrieve.
|
20
|
-
def retrieve(id, options = {})
|
21
|
-
body = (options.include? :query) ? options[:body] : {}
|
22
|
-
response = @client.get "#{PATH}/#{id.to_s}", body
|
23
|
-
end
|
24
|
-
|
25
|
-
#
|
26
|
-
# '/people' GET
|
27
|
-
#
|
28
|
-
def all(count = nil, offset = nil, options = {})
|
29
|
-
body = (options.include? :body) ? options[:body] : {}
|
30
|
-
|
31
|
-
body[:count] = count
|
32
|
-
body[:offset] = offset
|
33
|
-
|
34
|
-
@client.get PATH, body
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module BlockScore
|
2
|
-
class QuestionSets
|
3
|
-
PATH = '/question_sets'
|
4
|
-
|
5
|
-
def initialize(client)
|
6
|
-
@client = client
|
7
|
-
end
|
8
|
-
|
9
|
-
def create(person_id, options = {})
|
10
|
-
body = (options.include? :body) ? options[:body] : {}
|
11
|
-
body[:person_id] = person_id
|
12
|
-
|
13
|
-
response = @client.post PATH, body
|
14
|
-
end
|
15
|
-
|
16
|
-
#
|
17
|
-
# '/question_sets/:id/score' POST
|
18
|
-
#
|
19
|
-
# answers -
|
20
|
-
def score(id, answers)
|
21
|
-
body = {}
|
22
|
-
body[:answers] = answers
|
23
|
-
|
24
|
-
response = @client.post "#{PATH}/#{id.to_s}/score", body
|
25
|
-
end
|
26
|
-
|
27
|
-
#
|
28
|
-
# /question_sets/:id GET
|
29
|
-
#
|
30
|
-
# id -
|
31
|
-
def retrieve(id)
|
32
|
-
body = Hash.new
|
33
|
-
|
34
|
-
response = @client.get "#{PATH}/#{id.to_s}", body
|
35
|
-
end
|
36
|
-
|
37
|
-
#
|
38
|
-
# '/question_sets' GET
|
39
|
-
#
|
40
|
-
def all(count = nil, offset = nil, options = {})
|
41
|
-
body = (options.include? :body) ? options[:body] : {}
|
42
|
-
|
43
|
-
body[:count] = count
|
44
|
-
body[:offset] = offset
|
45
|
-
|
46
|
-
@client.get PATH, body
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module BlockScore
|
2
|
-
class Watchlists
|
3
|
-
PATH = '/watchlists'
|
4
|
-
|
5
|
-
def initialize(client)
|
6
|
-
@client = client
|
7
|
-
end
|
8
|
-
|
9
|
-
# POST https://api.blockscore.com/watchlists
|
10
|
-
def search(candidate_id, match_type = nil)
|
11
|
-
body = {}
|
12
|
-
body[:candidate_id] = candidate_id
|
13
|
-
body[:match_type] = match_type
|
14
|
-
|
15
|
-
@client.post PATH, body
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/test/helper.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'shoulda'
|
4
|
-
# require 'shoulda_context'
|
5
|
-
|
6
|
-
module SimpleCov::Configuration
|
7
|
-
def clean_filters
|
8
|
-
@filters = []
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
SimpleCov.configure do
|
13
|
-
clean_filters
|
14
|
-
load_profile 'test_frameworks'
|
15
|
-
end
|
16
|
-
|
17
|
-
ENV["COVERAGE"] && SimpleCov.start do
|
18
|
-
add_filter "/.rvm/"
|
19
|
-
end
|
20
|
-
require 'rubygems'
|
21
|
-
require 'bundler'
|
22
|
-
begin
|
23
|
-
Bundler.setup(:default, :development)
|
24
|
-
rescue Bundler::BundlerError => e
|
25
|
-
$stderr.puts e.message
|
26
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
27
|
-
exit e.status_code
|
28
|
-
end
|
29
|
-
require 'test/unit'
|
30
|
-
require 'shoulda'
|
31
|
-
|
32
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
33
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
34
|
-
require 'blockscore'
|
35
|
-
|
36
|
-
class Test::Unit::TestCase
|
37
|
-
end
|
data/test/test_blockscore.rb
DELETED
@@ -1,226 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
-
|
3
|
-
class TestBlockScore < Test::Unit::TestCase
|
4
|
-
# If you'd like to run the test suite, fill in your API key,
|
5
|
-
# a person ID, a question set ID, a company ID, and a candidate ID below.
|
6
|
-
@api_key = ""
|
7
|
-
|
8
|
-
@@person_id = ""
|
9
|
-
@@question_set_id = ""
|
10
|
-
@@company_id = ""
|
11
|
-
@@candidate_id = ""
|
12
|
-
|
13
|
-
@@client = BlockScore::Client.new(@api_key)
|
14
|
-
|
15
|
-
context "a watchlist" do
|
16
|
-
should "return search watchlists" do
|
17
|
-
response = @@client.watchlists.search(@@candidate_id)
|
18
|
-
assert_equal 200, response.code
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context "a candidate" do
|
23
|
-
should "return create a candidate" do
|
24
|
-
watchlist_params = {
|
25
|
-
:note => "12341234",
|
26
|
-
:ssn => "0001",
|
27
|
-
:date_of_birth => "1940-08-11",
|
28
|
-
:name_first => "John",
|
29
|
-
:name_middle => "",
|
30
|
-
:name_last => "Bredenkamp",
|
31
|
-
:address_street1 => "1 Infinite Loop",
|
32
|
-
:address_city => "Cupertino",
|
33
|
-
:address_country_code => "US"
|
34
|
-
}
|
35
|
-
response = @@client.candidates.create(watchlist_params)
|
36
|
-
assert_equal 201, response.code
|
37
|
-
end
|
38
|
-
|
39
|
-
should "return edit a candidate" do
|
40
|
-
watchlist_params = {
|
41
|
-
:date_of_birth => "1945-05-08",
|
42
|
-
:name_middle => "Jones"
|
43
|
-
}
|
44
|
-
response = @@client.candidates.edit(@@candidate_id, watchlist_params)
|
45
|
-
assert_equal 200, response.code
|
46
|
-
end
|
47
|
-
|
48
|
-
should "return retrieve a candidate" do
|
49
|
-
response = @@client.candidates.retrieve(@@candidate_id)
|
50
|
-
assert_equal 200, response.code
|
51
|
-
end
|
52
|
-
|
53
|
-
should "return a list of candidates" do
|
54
|
-
response = @@client.candidates.all
|
55
|
-
assert_equal 200, response.code
|
56
|
-
end
|
57
|
-
|
58
|
-
should "return a history of a candidate" do
|
59
|
-
response = @@client.candidates.history(@@candidate_id)
|
60
|
-
assert_equal 200, response.code
|
61
|
-
end
|
62
|
-
|
63
|
-
should "return the hits of a candidate" do
|
64
|
-
response = @@client.candidates.hits(@@candidate_id)
|
65
|
-
assert_equal 200, response.code
|
66
|
-
end
|
67
|
-
|
68
|
-
should "return delete a candidate" do
|
69
|
-
response = @@client.candidates.delete(@@candidate_id)
|
70
|
-
assert_equal 200, response.code
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
context "a company" do
|
76
|
-
should "return a list of companies" do
|
77
|
-
response = @@client.companies.all
|
78
|
-
assert_equal 200, response.code
|
79
|
-
end
|
80
|
-
|
81
|
-
should "return count = 2 companies" do
|
82
|
-
response = @@client.companies.all(count = 2)
|
83
|
-
assert_equal 200, response.code
|
84
|
-
end
|
85
|
-
|
86
|
-
should "return count=2 offset=2 companies" do
|
87
|
-
response = @@client.companies.all(count = 2, offset = 2)
|
88
|
-
assert_equal 200, response.code
|
89
|
-
end
|
90
|
-
|
91
|
-
should "return a single company" do
|
92
|
-
response = @@client.companies.retrieve(@@company_id)
|
93
|
-
assert_equal 200, response.code
|
94
|
-
end
|
95
|
-
|
96
|
-
should "return create a company" do
|
97
|
-
company_params = {
|
98
|
-
:entity_name => "BlockScore",
|
99
|
-
:tax_id => "123410000",
|
100
|
-
:incorporation_day => 25,
|
101
|
-
:incorporation_month => 8,
|
102
|
-
:incorporation_year => 1980,
|
103
|
-
:incorporation_state => "DE",
|
104
|
-
:incorporation_country_code => "US",
|
105
|
-
:incorporation_type => "corporation",
|
106
|
-
:dbas => "BitRemit",
|
107
|
-
:registration_number => "123123123",
|
108
|
-
:email => "test@example.com",
|
109
|
-
:url => "https://blockscore.com",
|
110
|
-
:phone_number => "6505555555",
|
111
|
-
:ip_address => "67.160.8.182",
|
112
|
-
:address_street1 => "1 Infinite Loop",
|
113
|
-
:address_street2 => nil,
|
114
|
-
:address_city => "Cupertino",
|
115
|
-
:address_subdivision => "CA",
|
116
|
-
:address_postal_code => "95014",
|
117
|
-
:address_country_code => "US"
|
118
|
-
}
|
119
|
-
|
120
|
-
response = @@client.companies.create(company_params)
|
121
|
-
|
122
|
-
assert_equal 201, response.code
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context "a person" do
|
127
|
-
should "return a list of people" do
|
128
|
-
response = @@client.people.all
|
129
|
-
assert_equal 200, response.code
|
130
|
-
end
|
131
|
-
|
132
|
-
should "return count = 2 people" do
|
133
|
-
response = @@client.people.all(count = 2)
|
134
|
-
assert_equal 200, response.code
|
135
|
-
end
|
136
|
-
|
137
|
-
should "return count=2 offset=2 people" do
|
138
|
-
response = @@client.people.all(count = 2, offset = 2)
|
139
|
-
assert_equal 200, response.code
|
140
|
-
end
|
141
|
-
|
142
|
-
should "return a single person" do
|
143
|
-
response = @@client.people.retrieve(@@person_id)
|
144
|
-
assert_equal 200, response.code
|
145
|
-
end
|
146
|
-
|
147
|
-
should "return create a person" do
|
148
|
-
people_params = {
|
149
|
-
:birth_day => 1,
|
150
|
-
:birth_month => 1,
|
151
|
-
:birth_year => 1975,
|
152
|
-
:document_type => "ssn",
|
153
|
-
:document_value => "0000",
|
154
|
-
:name_first => "John",
|
155
|
-
:name_middle => "P",
|
156
|
-
:name_last => "Doe",
|
157
|
-
:address_street1 => "1 Infinite Loop",
|
158
|
-
:address_street2 => nil,
|
159
|
-
:address_city => "Cupertino",
|
160
|
-
:address_subdivision => "CA",
|
161
|
-
:address_postal_code => "95014",
|
162
|
-
:address_country_code => "US"
|
163
|
-
}
|
164
|
-
|
165
|
-
response = @@client.people.create(people_params)
|
166
|
-
|
167
|
-
assert_equal 201, response.code
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context "a question set" do
|
172
|
-
should "return create a question set" do
|
173
|
-
response = @@client.question_sets.create(@@person_id)
|
174
|
-
assert_equal 201, response.code
|
175
|
-
end
|
176
|
-
|
177
|
-
should "return a single question set" do
|
178
|
-
response = @@client.question_sets.retrieve(@@question_set_id)
|
179
|
-
assert_equal 200, response.code
|
180
|
-
end
|
181
|
-
|
182
|
-
should "return a list of question sets" do
|
183
|
-
response = @@client.question_sets.all
|
184
|
-
assert_equal 200, response.code
|
185
|
-
end
|
186
|
-
|
187
|
-
should "return count = 2" do
|
188
|
-
response = @@client.question_sets.all(count = 2)
|
189
|
-
assert_equal 200, response.code
|
190
|
-
end
|
191
|
-
|
192
|
-
should "return count = 2 offset = 2" do
|
193
|
-
response = @@client.question_sets.all(count = 2, offset = 2)
|
194
|
-
assert_equal 200, response.code
|
195
|
-
end
|
196
|
-
|
197
|
-
should "return a score" do
|
198
|
-
@answers = [
|
199
|
-
{
|
200
|
-
:question_id => 1,
|
201
|
-
:answer_id => 1
|
202
|
-
},
|
203
|
-
{
|
204
|
-
:question_id => 2,
|
205
|
-
:answer_id => 1
|
206
|
-
},
|
207
|
-
{
|
208
|
-
:question_id => 3,
|
209
|
-
:answer_id => 1
|
210
|
-
},
|
211
|
-
{
|
212
|
-
:question_id => 4,
|
213
|
-
:answer_id => 1
|
214
|
-
},
|
215
|
-
{
|
216
|
-
:question_id => 5,
|
217
|
-
:answer_id => 1
|
218
|
-
}
|
219
|
-
]
|
220
|
-
|
221
|
-
response = @@client.question_sets.score(@@question_set_id, @answers)
|
222
|
-
|
223
|
-
assert_equal 201, response.code
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|