bigid_bgcheck 0.1.2 → 0.3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/LICENSE.txt +1 -1
- data/README.md +43 -29
- data/Rakefile +1 -1
- data/lib/bigid/bgcheck/request.rb +6 -2
- data/lib/bigid/bgcheck/result.rb +14 -8
- data/lib/bigid/bgcheck/version.rb +1 -1
- data/lib/bigid_bgcheck.rb +17 -19
- data/lib/locales/en.yml +17 -0
- data/lib/locales/pt-BR.yml +17 -0
- data/spec/bigid/bgcheck/bad_request_error_spec.rb +7 -0
- data/spec/bigid/bgcheck/base_error_spec.rb +7 -0
- data/spec/{lib → bigid}/bgcheck/doc_type_spec.rb +0 -1
- data/spec/bigid/bgcheck/document_not_supported_error_spec.rb +7 -0
- data/spec/bigid/bgcheck/internal_error_spec.rb +7 -0
- data/spec/bigid/bgcheck/invalid_credentials_error_spec.rb +7 -0
- data/spec/bigid/bgcheck/invalid_document_value_error_spec.rb +7 -0
- data/spec/bigid/bgcheck/no_info_error_spec.rb +7 -0
- data/spec/bigid/bgcheck/request_spec.rb +99 -0
- data/spec/{lib → bigid}/bgcheck/result_code_spec.rb +0 -1
- data/spec/bigid/bgcheck/server_error_spec.rb +7 -0
- data/spec/bigid_bgcheck_spec.rb +4 -23
- data/spec/factories/result.rb +45 -0
- data/spec/spec_helper.rb +29 -7
- data/spec/support/shared_examples/errors_shared_examples.rb +53 -0
- metadata +72 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3c762eb563f762b7422597ffb3854fc268a4d90737b31aedd8bf3eebb629987
|
4
|
+
data.tar.gz: f16a28500e579ca49a5f4b00e5dd632e005470bd3023a11585ec8633d93d7435
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b434e3f68d691114a83d6b27b9932b6e3112b41fb49748e4a6d387a475c169c66c2e47697138590198e9a503e8f8337334b05b237d38a86e7d9267c5ef362e97
|
7
|
+
data.tar.gz: 8a65f2b886f4603ea8f0bd4de448aad82b6c640ad98088a19c93f02d8d3ab8f4684e5b385ede0021f3a88496a55ee99b4d47b392b895ddbf3d7e470068d646ae
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# CHANGELOG for bigid_bgcheck
|
2
2
|
|
3
|
+
## v0.3.0
|
4
|
+
|
5
|
+
* Bump "bigid_auth" version from v0.1.0 to v0.2.0
|
6
|
+
|
7
|
+
## v0.2.0
|
8
|
+
|
9
|
+
Features
|
10
|
+
|
11
|
+
* Add fields to service return: "raw_data", "score_details", "related_score_details" and "raw_response" (the complete json file)
|
12
|
+
|
13
|
+
## v0.1.3
|
14
|
+
|
15
|
+
* Fix a problem with the locale initialization in Rails projects
|
16
|
+
|
3
17
|
## v0.1.2
|
4
18
|
|
5
19
|
* Move auth service to an external package
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,8 @@ BigId Background Check's Library for Ruby
|
|
2
2
|
==============
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/bigid_bgcheck.svg)](https://badge.fury.io/rb/bigid_bgcheck)
|
5
|
-
[![Build Status](https://travis-ci.com/Quasar-Flash/
|
5
|
+
[![Build Status](https://travis-ci.com/Quasar-Flash/bigid_bgcheck.svg?branch=master)](https://travis-ci.com/Quasar-Flash/bigid_bgcheck)
|
6
|
+
[![bigid_bgcheck](https://github.com/Quasar-Flash/bigid_bgcheck/actions/workflows/ruby.yml/badge.svg)](https://github.com/Quasar-Flash/bigid_bgcheck/actions/workflows/ruby.yml)
|
6
7
|
|
7
8
|
Requirements
|
8
9
|
-----------------
|
@@ -18,66 +19,79 @@ Included Modules
|
|
18
19
|
Global Installation
|
19
20
|
-----------------
|
20
21
|
|
21
|
-
|
22
|
+
```sh
|
23
|
+
gem install bigid_bgcheck
|
24
|
+
```
|
22
25
|
|
23
26
|
Installation for Rails
|
24
27
|
-----------------
|
25
28
|
|
26
|
-
|
27
|
-
|
29
|
+
```ruby
|
30
|
+
# Add to the Gemfile
|
31
|
+
gem "bigid_bgcheck", "~> 0.3"
|
32
|
+
gem "bigid_bgcheck", github: "Quasar-Flash/bigid_bgcheck"
|
33
|
+
```
|
28
34
|
|
29
35
|
Setting the BigID credentials
|
30
36
|
-----------------
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
```ruby
|
39
|
+
# Set the env variables
|
40
|
+
ENV["BIGID_USERNAME"] = "your_username"
|
41
|
+
ENV["BIGID_PASSWORD"] = "your_password"
|
42
|
+
```
|
35
43
|
|
36
44
|
Setting the BigID credentials - Rails Project
|
37
45
|
-----------------
|
38
46
|
|
39
47
|
Create the config/initializers/bigid.rb file and define:
|
40
48
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
49
|
+
```ruby
|
50
|
+
# Set the env variables
|
51
|
+
Bigid.configure do |config|
|
52
|
+
config.username = "your_username"
|
53
|
+
config.password = "your_password"
|
54
|
+
end
|
55
|
+
```
|
46
56
|
|
47
57
|
Applying a background check
|
48
58
|
-----------------
|
49
59
|
|
50
|
-
|
60
|
+
```ruby
|
61
|
+
require "bigid_bgcheck"
|
51
62
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
63
|
+
Bigid::Bgcheck::Request.new.call(
|
64
|
+
document: "000.000.000-00",
|
65
|
+
document_type: "CPF",
|
66
|
+
group: "Default"
|
67
|
+
)
|
68
|
+
```
|
57
69
|
|
58
70
|
Result Example
|
59
71
|
-----------------
|
60
72
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
73
|
+
```ruby
|
74
|
+
#<Bigid::Bgcheck::Result:0x0000560fef3c1068
|
75
|
+
@approved=false,
|
76
|
+
@ticket_id="00000000000000000",
|
77
|
+
@code=-1100,
|
78
|
+
@message="Not Approved",
|
79
|
+
@score=0,
|
80
|
+
@limit_score=0.0>
|
81
|
+
```
|
68
82
|
|
69
83
|
Problems?
|
70
84
|
-----------------
|
71
85
|
|
72
86
|
**Please do not directly email any committers with questions or problems.** A community is best served when discussions are held in public.
|
73
87
|
|
74
|
-
Searching the [issues](https://github.com/Quasar-Flash/
|
88
|
+
Searching the [issues](https://github.com/Quasar-Flash/bigid_bgcheck/issues) for your problem is also a good idea.
|
75
89
|
|
76
90
|
Contributing
|
77
91
|
-----------------
|
78
92
|
|
79
|
-
- Check out the latest master to make sure the feature hasn
|
80
|
-
- Check out the issue tracker to make sure someone already hasn
|
93
|
+
- Check out the latest master to make sure the feature hasn"t been implemented or the bug hasn't been fixed yet;
|
94
|
+
- Check out the issue tracker to make sure someone already hasn"t requested it and/or contributed it;
|
81
95
|
- Fork the project;
|
82
96
|
- Start a feature/bugfix branch;
|
83
97
|
- Commit and push until you are happy with your contribution;
|
@@ -87,7 +101,7 @@ Contributing
|
|
87
101
|
License
|
88
102
|
-----------------
|
89
103
|
|
90
|
-
Please see [LICENSE](https://github.com/Quasar-Flash/
|
104
|
+
Please see [LICENSE](https://github.com/Quasar-Flash/bigid_bgcheck/blob/master/LICENSE.txt) for licensing details.
|
91
105
|
|
92
106
|
Authors
|
93
107
|
-----------------
|
data/Rakefile
CHANGED
@@ -47,11 +47,15 @@ module Bigid
|
|
47
47
|
|
48
48
|
Bigid::Bgcheck::Result.new(
|
49
49
|
approved: ResultCode.approved?(body["ResultCode"]),
|
50
|
-
ticket_id: body["TicketId"],
|
51
50
|
code: body["ResultCode"],
|
51
|
+
score_details: body["ScoreDetails"],
|
52
|
+
limit_score: body["LimitScore"],
|
52
53
|
message: body["ResultMessage"],
|
54
|
+
raw_data: body["RawData"],
|
55
|
+
raw_response: body.to_json,
|
56
|
+
related_score_details: body["RelatedScoreDetails"],
|
53
57
|
score: body["Score"],
|
54
|
-
|
58
|
+
ticket_id: body["TicketId"]
|
55
59
|
)
|
56
60
|
end
|
57
61
|
end
|
data/lib/bigid/bgcheck/result.rb
CHANGED
@@ -3,15 +3,21 @@
|
|
3
3
|
module Bigid
|
4
4
|
module Bgcheck
|
5
5
|
class Result
|
6
|
-
attr_accessor :approved, :
|
6
|
+
attr_accessor :approved, :code, :score_details, :limit_score, :message, :raw_data,
|
7
|
+
:raw_response, :related_score_details, :score, :ticket_id
|
7
8
|
|
8
|
-
def initialize(approved:,
|
9
|
-
|
10
|
-
@
|
11
|
-
@code
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
9
|
+
def initialize(approved:, code:, score_details:, limit_score:, message:, raw_data:, raw_response:,
|
10
|
+
related_score_details:, score:, ticket_id:)
|
11
|
+
@approved = approved
|
12
|
+
@code = code
|
13
|
+
@score_details = score_details
|
14
|
+
@limit_score = limit_score
|
15
|
+
@message = message
|
16
|
+
@raw_data = raw_data
|
17
|
+
@raw_response = raw_response
|
18
|
+
@related_score_details = related_score_details
|
19
|
+
@score = score
|
20
|
+
@ticket_id = ticket_id
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|
@@ -9,6 +9,6 @@ module Bigid
|
|
9
9
|
# Major - Incremented for incompatible changes with previous release (or big enough new features)
|
10
10
|
# Minor - Incremented for new backwards-compatible features + deprecations
|
11
11
|
# Patch - Incremented for backwards-compatible bug fixes
|
12
|
-
VERSION = "0.
|
12
|
+
VERSION = "0.3.0.2"
|
13
13
|
end
|
14
14
|
end
|
data/lib/bigid_bgcheck.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "faraday"
|
4
3
|
require "i18n"
|
5
4
|
require "json"
|
5
|
+
require "cpf_cnpj"
|
6
6
|
|
7
7
|
require "bigid_auth"
|
8
8
|
|
@@ -22,30 +22,28 @@ require "bigid/bgcheck/result"
|
|
22
22
|
require "bigid/bgcheck/result_code"
|
23
23
|
require "bigid/bgcheck/request"
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
SRV_ENDPOINT = "backgroundcheck"
|
25
|
+
I18n.load_path += Dir[File.join(__dir__, "locales", "**/*.yml")]
|
26
|
+
I18n.reload! if I18n.backend.initialized?
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
module Bigid
|
29
|
+
class << self
|
30
|
+
attr_writer :configuration
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
end
|
32
|
+
def configuration
|
33
|
+
@configuration ||= Configuration.new
|
35
34
|
end
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
def self.configure
|
38
|
+
self.configuration ||= Configuration.new
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
yield(configuration)
|
41
|
+
end
|
42
42
|
|
43
|
-
|
44
|
-
|
43
|
+
class Configuration
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
I18n.default_locale = :en
|
49
|
-
I18n.reload!
|
46
|
+
module Bgcheck
|
47
|
+
SRV_ENDPOINT = "backgroundcheck"
|
50
48
|
end
|
51
49
|
end
|
data/lib/locales/en.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
en:
|
2
|
+
errors:
|
3
|
+
bigid:
|
4
|
+
auth:
|
5
|
+
authentication_error: An error ocurred during the authentication
|
6
|
+
bad_request_error: The request body or format is invalid
|
7
|
+
invalid_credentials_error: The credentials informed are invalid
|
8
|
+
server_error: An internal server error ocurred
|
9
|
+
bgcheck:
|
10
|
+
bad_request_error: The request body or format is invalid
|
11
|
+
document_not_supported_error: The document type is not supported
|
12
|
+
internal_error: An internal error on the BigId server ocurred
|
13
|
+
invalid_document_value_error: The document value is invalid
|
14
|
+
invalid_credentials_error: The credentials informed are invalid
|
15
|
+
no_info_error: No informations available
|
16
|
+
not_permission_error: Action not allowed
|
17
|
+
server_error: An internal server error ocurred
|
@@ -0,0 +1,17 @@
|
|
1
|
+
'pt-BR':
|
2
|
+
errors:
|
3
|
+
bigid:
|
4
|
+
auth:
|
5
|
+
authentication_error: Ocorreu um erro durante a autenticação
|
6
|
+
bad_request_error: O corpo ou formato da requisição é inválido
|
7
|
+
invalid_credentials_error: As credenciais informadas são inválidas
|
8
|
+
server_error: Ocorreu um erro inesperado no servidor
|
9
|
+
bgcheck:
|
10
|
+
bad_request_error: O corpo ou formato da requisição é inválido
|
11
|
+
document_not_supported_error: O tipo de documento é inválido
|
12
|
+
internal_error: Ocorreu um erro ao verificar a pessoa no BigId
|
13
|
+
invalid_document_value_error: O valor do documento é inválido
|
14
|
+
invalid_credentials_error: As credenciais informadas são inválidas
|
15
|
+
no_info_error: Sem informações disponíveis
|
16
|
+
not_permission_error: Ação não permitida
|
17
|
+
server_error: Ocorreu um erro inesperado no servidor
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
RSpec.describe Bigid::Bgcheck::Request do
|
6
|
+
describe "#call" do
|
7
|
+
let(:connection) { instance_double(Bigid::Auth::AuthenticatedConnection) }
|
8
|
+
let(:body) {
|
9
|
+
{
|
10
|
+
Login: "username_value",
|
11
|
+
parameters: { CNPJ: document },
|
12
|
+
Group: group
|
13
|
+
}.to_json
|
14
|
+
}
|
15
|
+
let(:success_result) { build(:result, :approved) }
|
16
|
+
let(:success_result_response) {
|
17
|
+
JSON.parse({
|
18
|
+
body: {
|
19
|
+
RawData: success_result.raw_data,
|
20
|
+
ScoreDetails: success_result.score_details,
|
21
|
+
RelatedScoreDetails: success_result.related_score_details,
|
22
|
+
LimitScore: success_result.limit_score,
|
23
|
+
ResultCode: success_result.code,
|
24
|
+
ResultMessage: success_result.message,
|
25
|
+
Score: success_result.score,
|
26
|
+
TicketId: success_result.ticket_id
|
27
|
+
}.to_json,
|
28
|
+
status: request_status
|
29
|
+
}.to_json, object_class: OpenStruct)
|
30
|
+
}
|
31
|
+
let(:document) { CNPJ.generate }
|
32
|
+
let(:document_type) { "CNPJ" }
|
33
|
+
let(:group) { "Default" }
|
34
|
+
let(:request_status) { 200 }
|
35
|
+
|
36
|
+
subject { described_class.new.call(document: document, document_type: document_type, group: group) }
|
37
|
+
|
38
|
+
before do
|
39
|
+
allow(Bigid::Auth::AuthenticatedConnection).to receive(:new).and_return(connection)
|
40
|
+
allow(connection).to receive(:post).and_return(success_result_response)
|
41
|
+
end
|
42
|
+
|
43
|
+
describe ".call" do
|
44
|
+
subject { described_class.call(document: document, document_type: document_type, group: group) }
|
45
|
+
|
46
|
+
it { expect(subject).to be_kind_of(Bigid::Bgcheck::Result) }
|
47
|
+
|
48
|
+
it { subject; expect(connection).to have_received(:post) }
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when all parameters are valid" do
|
52
|
+
it { expect(subject).to be_kind_of(Bigid::Bgcheck::Result) }
|
53
|
+
|
54
|
+
it { subject; expect(connection).to have_received(:post) }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when document type is invalid" do
|
58
|
+
let(:document_type) { "CNP" }
|
59
|
+
|
60
|
+
it { expect { subject }.to raise_error(Bigid::Bgcheck::DocumentNotSupportedError) }
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when request status is null" do
|
64
|
+
let(:request_status) { nil }
|
65
|
+
|
66
|
+
it { expect { subject }.to raise_error(Bigid::Bgcheck::InternalError) }
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when request status is server error" do
|
70
|
+
let(:request_status) { 500 }
|
71
|
+
|
72
|
+
it { expect { subject }.to raise_error(Bigid::Bgcheck::ServerError) }
|
73
|
+
end
|
74
|
+
|
75
|
+
context "when request status is auth error" do
|
76
|
+
let(:request_status) { 401 }
|
77
|
+
|
78
|
+
it { expect { subject }.to raise_error(Bigid::Bgcheck::InvalidCredentialsError) }
|
79
|
+
end
|
80
|
+
|
81
|
+
context "when request status is bad request" do
|
82
|
+
let(:request_status) { 400 }
|
83
|
+
|
84
|
+
it { expect { subject }.to raise_error(Bigid::Bgcheck::BadRequestError) }
|
85
|
+
end
|
86
|
+
|
87
|
+
context "when the result code is empty" do
|
88
|
+
let(:success_result) { build(:result, :approved, code: nil) }
|
89
|
+
|
90
|
+
it { expect { subject }.to raise_error(Bigid::Bgcheck::InvalidDocumentValueError) }
|
91
|
+
end
|
92
|
+
|
93
|
+
context "when the result code is empty" do
|
94
|
+
let(:success_result) { build(:result, :approved, code: Bigid::Bgcheck::ResultCode::NO_INFO) }
|
95
|
+
|
96
|
+
it { expect { subject }.to raise_error(Bigid::Bgcheck::NoInfoError) }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/spec/bigid_bgcheck_spec.rb
CHANGED
@@ -1,44 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
|
-
require "bigid_bgcheck"
|
5
4
|
|
6
5
|
RSpec.describe Bigid::Bgcheck do
|
7
|
-
describe "BASE_URL" do
|
8
|
-
subject { defined? Bigid::Bgcheck::BASE_URL }
|
9
|
-
|
10
|
-
it { expect(subject).to be_truthy }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "AUTH_ENDPOINT" do
|
14
|
-
subject { defined? Bigid::Bgcheck::AUTH_ENDPOINT }
|
15
|
-
|
16
|
-
it { expect(subject).to be_truthy }
|
17
|
-
end
|
18
|
-
|
19
6
|
describe "SRV_ENDPOINT" do
|
20
7
|
subject { defined? Bigid::Bgcheck::SRV_ENDPOINT }
|
21
8
|
|
22
9
|
it { expect(subject).to be_truthy }
|
23
10
|
end
|
24
11
|
|
25
|
-
describe "TOKEN_EXPIRATION" do
|
26
|
-
subject { defined? Bigid::Bgcheck::TOKEN_EXPIRATION }
|
27
|
-
|
28
|
-
it { expect(subject).to be_truthy }
|
29
|
-
end
|
30
|
-
|
31
12
|
describe ".configure" do
|
32
13
|
before do
|
33
|
-
|
14
|
+
Bigid.configuration = nil
|
34
15
|
ENV.clear
|
35
16
|
end
|
36
17
|
|
37
|
-
subject {
|
18
|
+
subject { Bigid.configuration }
|
38
19
|
|
39
20
|
context "when configuration is defined" do
|
40
21
|
before do
|
41
|
-
|
22
|
+
Bigid.configure do |config|
|
42
23
|
config.username = "username_value"
|
43
24
|
config.password = "password_value"
|
44
25
|
end
|
@@ -77,7 +58,7 @@ RSpec.describe Bigid::Bgcheck do
|
|
77
58
|
ENV["BIGID_USERNAME"] = "username_value"
|
78
59
|
ENV["BIGID_PASSWORD"] = "password_value"
|
79
60
|
|
80
|
-
|
61
|
+
Bigid.configure do |config|
|
81
62
|
config.username = "username_value2"
|
82
63
|
config.password = "password_value2"
|
83
64
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
FactoryBot.define do
|
4
|
+
factory :result, class: "Bigid::Bgcheck::Result" do
|
5
|
+
trait :approved do
|
6
|
+
approved { true }
|
7
|
+
code { Bigid::Bgcheck::ResultCode::APPROVED }
|
8
|
+
score_details { {} }
|
9
|
+
limit_score { 10.0 }
|
10
|
+
message { "Approved" }
|
11
|
+
score { 10.0 }
|
12
|
+
ticket_id { SecureRandom.hex(8) }
|
13
|
+
raw_data { "{}" }
|
14
|
+
raw_response { "{\"ScoreDetails\":#{score_details},\"LimitScore\":#{limit_score},\"ResultCode\":#{code},\"ResultMessage\":\"#{message}\",\"Score\":#{score},\"TicketId\":\"#{ticket_id}\"}" }
|
15
|
+
related_score_details { "{}" }
|
16
|
+
end
|
17
|
+
|
18
|
+
trait :unapproved do
|
19
|
+
approved { false }
|
20
|
+
code { Bigid::Bgcheck::ResultCode::NOT_APPROVED }
|
21
|
+
score_details { }
|
22
|
+
limit_score { 10.0 }
|
23
|
+
message { "Not Approved" }
|
24
|
+
raw_response { "{\"ScoreDetails\":null,\"LimitScore\":10.0,\"ResultCode\":90,\"ResultMessage\":\"Approved\",\"Score\":10.0,\"TicketId\":\"d735711aeb909de9\"}" }
|
25
|
+
score { 1.0 }
|
26
|
+
ticket_id { SecureRandom.hex(8) }
|
27
|
+
end
|
28
|
+
|
29
|
+
initialize_with do
|
30
|
+
new(
|
31
|
+
approved: approved,
|
32
|
+
code: code,
|
33
|
+
score_details: score_details,
|
34
|
+
limit_score: limit_score,
|
35
|
+
message: message,
|
36
|
+
raw_data: raw_data,
|
37
|
+
raw_response: raw_response,
|
38
|
+
related_score_details: related_score_details,
|
39
|
+
score: score,
|
40
|
+
score_details: score_details,
|
41
|
+
ticket_id: ticket_id
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "simplecov"
|
4
|
+
|
5
|
+
SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter]
|
6
|
+
SimpleCov.minimum_coverage 70.0
|
7
|
+
|
8
|
+
SimpleCov.start do
|
9
|
+
add_filter "/spec/"
|
10
|
+
minimum_coverage 70
|
11
|
+
minimum_coverage_by_file 50
|
12
|
+
end
|
13
|
+
|
14
|
+
require "bigid_auth"
|
15
|
+
require "bigid/bgcheck/base_error"
|
16
|
+
|
17
|
+
Dir["./spec/support/**/*.rb"].each { |f| require f }
|
18
|
+
Dir["./spec/initializers/**/*.rb"].each { |f| require f }
|
19
|
+
Dir["./lib/**/*.rb"].sort.each { |file| require file }
|
20
|
+
|
3
21
|
require "rubygems"
|
4
22
|
require "bundler"
|
23
|
+
require "bigid_bgcheck"
|
24
|
+
require "factory_bot"
|
25
|
+
require "pry"
|
5
26
|
|
6
27
|
begin
|
7
28
|
Bundler.setup(:default, :development, :test)
|
@@ -12,14 +33,15 @@ rescue Bundler::BundlerError => e
|
|
12
33
|
exit e.status_code
|
13
34
|
end
|
14
35
|
|
15
|
-
|
36
|
+
RSpec.configure do |config|
|
37
|
+
config.include FactoryBot::Syntax::Methods
|
16
38
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
39
|
+
# Enable flags like --only-failures and --next-failure
|
40
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
20
41
|
|
21
|
-
|
22
|
-
|
42
|
+
config.expect_with :rspec do |c|
|
43
|
+
c.syntax = :expect
|
44
|
+
end
|
23
45
|
end
|
24
46
|
|
25
|
-
|
47
|
+
FactoryBot.find_definitions
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
RSpec.shared_examples "error" do
|
6
|
+
describe ".initialize" do
|
7
|
+
context "when message parameter is null" do
|
8
|
+
subject { described_class.new.message }
|
9
|
+
|
10
|
+
it { expect(subject).to eq(described_class.default_message) }
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when message parameter is not null" do
|
14
|
+
subject { described_class.new(message).message }
|
15
|
+
|
16
|
+
let(:message) { "message" }
|
17
|
+
|
18
|
+
it { expect(subject).to eq(message) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".default_message" do
|
23
|
+
let(:expected_result) { I18n.t("errors.#{described_class.name.underscore.tr("/", ".")}") }
|
24
|
+
|
25
|
+
subject { described_class.default_message }
|
26
|
+
|
27
|
+
it "searches the default message in I18n using the class name" do
|
28
|
+
expect(subject).to eq(expected_result)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
RSpec.shared_examples "http_error" do
|
34
|
+
include_examples "error"
|
35
|
+
|
36
|
+
describe "#http_status" do
|
37
|
+
subject { described_class.new.http_status }
|
38
|
+
|
39
|
+
it { expect(subject).to eq(described_class::HTTP_STATUS) }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#status" do
|
43
|
+
subject { described_class.new.status }
|
44
|
+
|
45
|
+
it { expect(subject).to eq(described_class::STATUS) }
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#status_code" do
|
49
|
+
subject { described_class.new.status_code }
|
50
|
+
|
51
|
+
it { expect(subject).to eq(described_class::STATUS_CODE) }
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigid_bgcheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Carolino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigid_auth
|
@@ -16,27 +16,27 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.2'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '0.
|
22
|
+
version: '0.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: '0.2'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '0.
|
32
|
+
version: '0.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: i18n
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 1.
|
39
|
+
version: '1.8'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '1.0'
|
@@ -46,106 +46,106 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.
|
49
|
+
version: '1.8'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '1.0'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
54
|
+
name: json
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
59
|
+
version: '2.5'
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '2.0'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: '2.5'
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
72
|
+
version: '2.0'
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
74
|
+
name: cpf_cnpj
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
77
|
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
79
|
+
version: '0.5'
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0.5'
|
83
83
|
type: :runtime
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '0.5'
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: '
|
92
|
+
version: '0.5'
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: bundler
|
95
95
|
requirement: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
97
|
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version: 1.2
|
99
|
+
version: '1.2'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
102
|
version_requirements: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version: 1.2
|
106
|
+
version: '1.2'
|
107
107
|
- !ruby/object:Gem::Dependency
|
108
108
|
name: factory_bot
|
109
109
|
requirement: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
111
|
- - "~>"
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
version: 6.
|
113
|
+
version: '6.2'
|
114
114
|
type: :development
|
115
115
|
prerelease: false
|
116
116
|
version_requirements: !ruby/object:Gem::Requirement
|
117
117
|
requirements:
|
118
118
|
- - "~>"
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: 6.
|
120
|
+
version: '6.2'
|
121
121
|
- !ruby/object:Gem::Dependency
|
122
|
-
name:
|
122
|
+
name: fuubar
|
123
123
|
requirement: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
125
|
- - "~>"
|
126
126
|
- !ruby/object:Gem::Version
|
127
|
-
version: '
|
127
|
+
version: '2.5'
|
128
128
|
type: :development
|
129
129
|
prerelease: false
|
130
130
|
version_requirements: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
132
|
- - "~>"
|
133
133
|
- !ruby/object:Gem::Version
|
134
|
-
version: '
|
134
|
+
version: '2.5'
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: pry
|
137
137
|
requirement: !ruby/object:Gem::Requirement
|
138
138
|
requirements:
|
139
139
|
- - "~>"
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version: 0.14
|
141
|
+
version: '0.14'
|
142
142
|
type: :development
|
143
143
|
prerelease: false
|
144
144
|
version_requirements: !ruby/object:Gem::Requirement
|
145
145
|
requirements:
|
146
146
|
- - "~>"
|
147
147
|
- !ruby/object:Gem::Version
|
148
|
-
version: 0.14
|
148
|
+
version: '0.14'
|
149
149
|
- !ruby/object:Gem::Dependency
|
150
150
|
name: rake
|
151
151
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,70 +172,70 @@ dependencies:
|
|
172
172
|
requirements:
|
173
173
|
- - "~>"
|
174
174
|
- !ruby/object:Gem::Version
|
175
|
-
version: 3.10
|
175
|
+
version: '3.10'
|
176
176
|
type: :development
|
177
177
|
prerelease: false
|
178
178
|
version_requirements: !ruby/object:Gem::Requirement
|
179
179
|
requirements:
|
180
180
|
- - "~>"
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: 3.10
|
182
|
+
version: '3.10'
|
183
183
|
- !ruby/object:Gem::Dependency
|
184
184
|
name: rubocop
|
185
185
|
requirement: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
187
|
- - "~>"
|
188
188
|
- !ruby/object:Gem::Version
|
189
|
-
version: 1.
|
189
|
+
version: '1.17'
|
190
190
|
type: :development
|
191
191
|
prerelease: false
|
192
192
|
version_requirements: !ruby/object:Gem::Requirement
|
193
193
|
requirements:
|
194
194
|
- - "~>"
|
195
195
|
- !ruby/object:Gem::Version
|
196
|
-
version: 1.
|
196
|
+
version: '1.17'
|
197
197
|
- !ruby/object:Gem::Dependency
|
198
198
|
name: rubocop-packaging
|
199
199
|
requirement: !ruby/object:Gem::Requirement
|
200
200
|
requirements:
|
201
201
|
- - "~>"
|
202
202
|
- !ruby/object:Gem::Version
|
203
|
-
version: 0.5
|
203
|
+
version: '0.5'
|
204
204
|
type: :development
|
205
205
|
prerelease: false
|
206
206
|
version_requirements: !ruby/object:Gem::Requirement
|
207
207
|
requirements:
|
208
208
|
- - "~>"
|
209
209
|
- !ruby/object:Gem::Version
|
210
|
-
version: 0.5
|
210
|
+
version: '0.5'
|
211
211
|
- !ruby/object:Gem::Dependency
|
212
212
|
name: rubocop-performance
|
213
213
|
requirement: !ruby/object:Gem::Requirement
|
214
214
|
requirements:
|
215
215
|
- - "~>"
|
216
216
|
- !ruby/object:Gem::Version
|
217
|
-
version: 1.
|
217
|
+
version: '1.11'
|
218
218
|
type: :development
|
219
219
|
prerelease: false
|
220
220
|
version_requirements: !ruby/object:Gem::Requirement
|
221
221
|
requirements:
|
222
222
|
- - "~>"
|
223
223
|
- !ruby/object:Gem::Version
|
224
|
-
version: 1.
|
224
|
+
version: '1.11'
|
225
225
|
- !ruby/object:Gem::Dependency
|
226
226
|
name: simplecov
|
227
227
|
requirement: !ruby/object:Gem::Requirement
|
228
228
|
requirements:
|
229
229
|
- - "~>"
|
230
230
|
- !ruby/object:Gem::Version
|
231
|
-
version: 0.21.
|
231
|
+
version: 0.21.2
|
232
232
|
type: :development
|
233
233
|
prerelease: false
|
234
234
|
version_requirements: !ruby/object:Gem::Requirement
|
235
235
|
requirements:
|
236
236
|
- - "~>"
|
237
237
|
- !ruby/object:Gem::Version
|
238
|
-
version: 0.21.
|
238
|
+
version: 0.21.2
|
239
239
|
description: A library to use BigData Corps background check features
|
240
240
|
email:
|
241
241
|
- danilo.carolino@qflash.com.br
|
@@ -261,14 +261,30 @@ files:
|
|
261
261
|
- lib/bigid/bgcheck/server_error.rb
|
262
262
|
- lib/bigid/bgcheck/version.rb
|
263
263
|
- lib/bigid_bgcheck.rb
|
264
|
+
- lib/locales/en.yml
|
265
|
+
- lib/locales/pt-BR.yml
|
266
|
+
- spec/bigid/bgcheck/bad_request_error_spec.rb
|
267
|
+
- spec/bigid/bgcheck/base_error_spec.rb
|
268
|
+
- spec/bigid/bgcheck/doc_type_spec.rb
|
269
|
+
- spec/bigid/bgcheck/document_not_supported_error_spec.rb
|
270
|
+
- spec/bigid/bgcheck/internal_error_spec.rb
|
271
|
+
- spec/bigid/bgcheck/invalid_credentials_error_spec.rb
|
272
|
+
- spec/bigid/bgcheck/invalid_document_value_error_spec.rb
|
273
|
+
- spec/bigid/bgcheck/no_info_error_spec.rb
|
274
|
+
- spec/bigid/bgcheck/request_spec.rb
|
275
|
+
- spec/bigid/bgcheck/result_code_spec.rb
|
276
|
+
- spec/bigid/bgcheck/server_error_spec.rb
|
264
277
|
- spec/bigid_bgcheck_spec.rb
|
265
|
-
- spec/
|
266
|
-
- spec/lib/bgcheck/result_code_spec.rb
|
278
|
+
- spec/factories/result.rb
|
267
279
|
- spec/spec_helper.rb
|
268
|
-
|
280
|
+
- spec/support/shared_examples/errors_shared_examples.rb
|
281
|
+
homepage: https://github.com/Quasar-Flash/bigid_bgcheck
|
269
282
|
licenses:
|
270
283
|
- MIT
|
271
|
-
metadata:
|
284
|
+
metadata:
|
285
|
+
changelog_uri: https://github.com/Quasar-Flash/bigid_bgcheck/blob/master/CHANGELOG.md
|
286
|
+
source_code_uri: https://github.com/Quasar-Flash/bigid_bgcheck
|
287
|
+
bug_tracker_uri: https://github.com/Quasar-Flash/bigid_bgcheck/issues
|
272
288
|
post_install_message:
|
273
289
|
rdoc_options: []
|
274
290
|
require_paths:
|
@@ -277,7 +293,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
277
293
|
requirements:
|
278
294
|
- - ">="
|
279
295
|
- !ruby/object:Gem::Version
|
280
|
-
version: '
|
296
|
+
version: '2.5'
|
281
297
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
282
298
|
requirements:
|
283
299
|
- - ">="
|
@@ -290,6 +306,17 @@ specification_version: 4
|
|
290
306
|
summary: Bigid Background Check Library
|
291
307
|
test_files:
|
292
308
|
- spec/bigid_bgcheck_spec.rb
|
293
|
-
- spec/
|
294
|
-
- spec/
|
309
|
+
- spec/support/shared_examples/errors_shared_examples.rb
|
310
|
+
- spec/factories/result.rb
|
295
311
|
- spec/spec_helper.rb
|
312
|
+
- spec/bigid/bgcheck/invalid_document_value_error_spec.rb
|
313
|
+
- spec/bigid/bgcheck/bad_request_error_spec.rb
|
314
|
+
- spec/bigid/bgcheck/no_info_error_spec.rb
|
315
|
+
- spec/bigid/bgcheck/internal_error_spec.rb
|
316
|
+
- spec/bigid/bgcheck/result_code_spec.rb
|
317
|
+
- spec/bigid/bgcheck/server_error_spec.rb
|
318
|
+
- spec/bigid/bgcheck/request_spec.rb
|
319
|
+
- spec/bigid/bgcheck/invalid_credentials_error_spec.rb
|
320
|
+
- spec/bigid/bgcheck/document_not_supported_error_spec.rb
|
321
|
+
- spec/bigid/bgcheck/doc_type_spec.rb
|
322
|
+
- spec/bigid/bgcheck/base_error_spec.rb
|