blockscore 2.0.1 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6572d9025db7922729dfa782a8a3862cd3a5c4c
4
- data.tar.gz: e3362c4ff984588c2e676618d361397a0b8235dd
3
+ metadata.gz: 9e7e9be7f4741751bb2d8f05439f2f955eb4f666
4
+ data.tar.gz: 20939949826f3f40d4cb81a325819e326818e597
5
5
  SHA512:
6
- metadata.gz: 21d29e52127480c3c8e9753a42ff32c1222d60cb14b197442a2d5a952ae5079c212cb002a7af31c509d832c04aaad6c4f9787037113ed446860896d0cea3cbf1
7
- data.tar.gz: 3670fa3f75bef1977c331be5e272b16bf4480bff37d19c91831316f29ec7aa746d08ca8adf70593706602ad3290f46e13208a45b913412fa88be5b964e4b47da
6
+ metadata.gz: c41056637f672fed83e96a7960348fb2152b4b850277d6c6a4f39c8c154c588c1f1ce755b479e21a2762c5f0dc9d7cef93d8d741cd890bd3875ae6be0cbe2a4e
7
+ data.tar.gz: 67315cbc4dbdd5f3c234b59987782a70a43ed8dba10202a7cffc4110aefcef6f784e384c46bc13dc345ac5fc74f02ee7a1fd85666ea71304edf2f7ce2a5b23d7
data/README.md CHANGED
@@ -13,7 +13,7 @@ gem install blockscore
13
13
  If you are using Rails, add the following to your `Gemfile`:
14
14
 
15
15
  ```ruby
16
- gem 'blockscore', '~> 2.0.0'
16
+ gem 'blockscore', '~> 2.0.1'
17
17
  ```
18
18
 
19
19
  ## Getting Started
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.1.0
@@ -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.1 ruby lib
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.1"
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-22"
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",
@@ -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
- @message = message
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(verification_id, question_set_id, answers)
22
-
23
- body = {
24
- :verification_id => verification_id,
25
- :question_set_id => question_set_id,
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 POST
27
+ # /questions/:id GET
34
28
  #
35
29
  # question_set_id -
36
30
  # verification_id -
37
- def retrieve(question_set_id, verification_id)
31
+ def retrieve(id)
38
32
  body = Hash.new
39
- body[:verification_id] = verification_id
40
33
 
41
- response = @client.post "/questions/#{question_set_id.to_s}", body
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
@@ -1,39 +1,90 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
2
 
3
3
  class TestBlockScore < Test::Unit::TestCase
4
- context "a verification" do
5
- setup do
6
- # If you'd like to run the test suite, fill in your API key,
7
- # a verification ID and a question set ID below.
8
- @client = BlockScore::Client.new("Your API key", version = 2)
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
- @verification_id = "Your verification ID"
11
- @question_set_id = "Your question set ID"
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 = @client.verification.all
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 = @client.verification.all(count = 2)
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 = @client.verification.all(count = 2, offset = 2)
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 = @client.verification.retrieve(@verification_id)
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
- :country => "US"
103
+ :country_code => "US"
53
104
  }
54
105
  }
55
106
 
56
- response = @client.verification.create(verification_params)
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 = @client.question_set.create(@verification_id)
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 = @client.question_set.retrieve(@question_set_id, @verification_id)
68
- assert_equal 201, response.code
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 = @client.question_set.all
125
+ response = @@client.question_set.all
73
126
  assert_equal 200, response.code
74
127
  end
75
128
 
76
- should "return count = 2 question sets" do
77
- response = @client.question_set.all(count = 2)
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 question sets" do
82
- response = @client.question_set.all(count = 2, offset = 2)
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 for the question set" do
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 = @client.question_set.score(
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.1
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-22 00:00:00.000000000 Z
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