diff --git a/README.md b/README.md index 5f1181b..7dde622 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,15 @@ Or install it yourself as: report.id #Returns the checkr id of the created report report.status #Returns the status of the report ``` + +**Update report** + + ```Ruby + report = Checkr::Report.update("5878551b3ee1eacae5a2c558", :package => 'driver_pro') + report.id #Returns the checkr id of the updated report + report.package #Returns the updated package of the report + ``` + **Find individual reports** ```Ruby diff --git a/lib/checkr/report.rb b/lib/checkr/report.rb index a6dc4ce..6dc704d 100644 --- a/lib/checkr/report.rb +++ b/lib/checkr/report.rb @@ -13,6 +13,11 @@ def self.find(id) handle_response(response) end + def self.update(id, params={}) + response = self.post("/#{self.to_s.tablelize}/#{id}", :body => params, :basic_auth => Checkr.auth ) + handle_response(response) + end + def self.construct(params) records = params["records"] report = self.new(params.except_key('records')) diff --git a/test/cassettes/test_0001_should_return_report_object.yml b/test/cassettes/test_0001_should_return_report_object.yml index a88288c..825652e 100644 --- a/test/cassettes/test_0001_should_return_report_object.yml +++ b/test/cassettes/test_0001_should_return_report_object.yml @@ -36,6 +36,44 @@ http_interactions: body: encoding: UTF-8 string: '{"id":"5878551b3ee1eacae5a2c558","object":"test_report","uri":"/v1/reports/5878551b3ee1eacae5a2c558","status":"pending","created_at":"2014-10-14T07:10:16Z","completed_at":null,"upgraded_at":null,"turnaround_time":null,"package":"driver_plus","tags":[],"candidate_id":"e44aa283528e6fde7d542194","ssn_trace_id":"543ccc5835396200064a0000","sex_offender_search_id":"543ccc583539620006510000","terrorist_watchlist_search_id":"543ccc583539620006520000","national_criminal_search_id":"543ccc5835396200064f0000","county_criminal_search_ids":["543ccc583539620006530000","543ccc583539620006540000","543ccc593539620006550000","543ccc593539620006560000"],"motor_vehicle_report_id":"543ccc583539620006500000","geo_id":null,"document_ids":[]}' - http_version: + http_version: + recorded_at: Tue, 14 Oct 2014 07:16:40 GMT +- request: + method: post + uri: https://83ebeabdec09f6670863766f792ead24d61fe3f9:@api.checkr.io/v1/reports/5878551b3ee1eacae5a2c558 + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Server: + - Cowboy + Connection: + - keep-alive + Date: + - Tue, 14 Oct 2014 07:16:40 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Content-Type: + - application/json + Content-Length: + - '728' + X-Content-Type-Options: + - nosniff + Set-Cookie: + - checkr.production=BAh7CEkiD3Nlc3Npb25faWQGOgZFVEkiRTlhODMzOGUwZjYzOGRhZDU2Mzg4%0AZjg1NWU5ZjJiNzFlN2Q5MmIzMWRlZTAyNTdhYWY4NjRmM2EzN2E5YWYzN2UG%0AOwBGSSIJY3NyZgY7AEZJIiVhM2UzNDAyYzhlMDM0NjcyYTcwY2NmZWE5ZWY4%0AMWRjZAY7AEZJIg10cmFja2luZwY7AEZ7B0kiFEhUVFBfVVNFUl9BR0VOVAY7%0AAFRJIi1kYTM5YTNlZTVlNmI0YjBkMzI1NWJmZWY5NTYwMTg5MGFmZDgwNzA5%0ABjsARkkiGUhUVFBfQUNDRVBUX0xBTkdVQUdFBjsAVEkiLWRhMzlhM2VlNWU2%0AYjRiMGQzMjU1YmZlZjk1NjAxODkwYWZkODA3MDkGOwBG%0A--8ef011e68f25fee896ac92ba9ef0574655e532bf; + path=/; HttpOnly; secure + Via: + - 1.1 vegur + body: + encoding: UTF-8 + string: '{"id":"5878551b3ee1eacae5a2c558","object":"test_report","uri":"/v1/reports/5878551b3ee1eacae5a2c558","status":"pending","created_at":"2014-10-14T07:10:16Z","completed_at":null,"upgraded_at":null,"turnaround_time":null,"package":"driver_pro","tags":[],"candidate_id":"e44aa283528e6fde7d542194","ssn_trace_id":"543ccc5835396200064a0000","sex_offender_search_id":"543ccc583539620006510000","terrorist_watchlist_search_id":"543ccc583539620006520000","national_criminal_search_id":"543ccc5835396200064f0000","county_criminal_search_ids":["543ccc583539620006530000","543ccc583539620006540000","543ccc593539620006550000","543ccc593539620006560000"],"motor_vehicle_report_id":"543ccc583539620006500000","geo_id":null,"document_ids":[]}' + http_version: recorded_at: Tue, 14 Oct 2014 07:16:40 GMT recorded_with: VCR 2.9.3 diff --git a/test/cassettes/test_0002_returns_report_object_with_updated_parameters.yml b/test/cassettes/test_0002_returns_report_object_with_updated_parameters.yml new file mode 100644 index 0000000..19ad4dc --- /dev/null +++ b/test/cassettes/test_0002_returns_report_object_with_updated_parameters.yml @@ -0,0 +1,41 @@ +--- +http_interactions: +- request: + method: post + uri: https://83ebeabdec09f6670863766f792ead24d61fe3f9:@api.checkr.io/v1/reports/5878551b3ee1eacae5a2c558 + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Server: + - Cowboy + Connection: + - keep-alive + Date: + - Tue, 14 Oct 2014 07:16:40 GMT + Status: + - 200 OK + Strict-Transport-Security: + - max-age=31536000 + Content-Type: + - application/json + Content-Length: + - '728' + X-Content-Type-Options: + - nosniff + Set-Cookie: + - checkr.production=BAh7CEkiD3Nlc3Npb25faWQGOgZFVEkiRTlhODMzOGUwZjYzOGRhZDU2Mzg4%0AZjg1NWU5ZjJiNzFlN2Q5MmIzMWRlZTAyNTdhYWY4NjRmM2EzN2E5YWYzN2UG%0AOwBGSSIJY3NyZgY7AEZJIiVhM2UzNDAyYzhlMDM0NjcyYTcwY2NmZWE5ZWY4%0AMWRjZAY7AEZJIg10cmFja2luZwY7AEZ7B0kiFEhUVFBfVVNFUl9BR0VOVAY7%0AAFRJIi1kYTM5YTNlZTVlNmI0YjBkMzI1NWJmZWY5NTYwMTg5MGFmZDgwNzA5%0ABjsARkkiGUhUVFBfQUNDRVBUX0xBTkdVQUdFBjsAVEkiLWRhMzlhM2VlNWU2%0AYjRiMGQzMjU1YmZlZjk1NjAxODkwYWZkODA3MDkGOwBG%0A--8ef011e68f25fee896ac92ba9ef0574655e532bf; + path=/; HttpOnly; secure + Via: + - 1.1 vegur + body: + encoding: UTF-8 + string: '{"id":"5878551b3ee1eacae5a2c558","object":"test_report","uri":"/v1/reports/5878551b3ee1eacae5a2c558","status":"pending","created_at":"2014-10-14T07:10:16Z","completed_at":null,"upgraded_at":null,"turnaround_time":null,"package":"driver_pro","tags":[],"candidate_id":"e44aa283528e6fde7d542194","ssn_trace_id":"543ccc5835396200064a0000","sex_offender_search_id":"543ccc583539620006510000","terrorist_watchlist_search_id":"543ccc583539620006520000","national_criminal_search_id":"543ccc5835396200064f0000","county_criminal_search_ids":["543ccc583539620006530000","543ccc583539620006540000","543ccc593539620006550000","543ccc593539620006560000"],"motor_vehicle_report_id":"543ccc583539620006500000","geo_id":null,"document_ids":[]}' + http_version: + recorded_at: Tue, 14 Oct 2014 07:16:40 GMT +recorded_with: VCR 3.0.0 diff --git a/test/lib/checkr/report_test.rb b/test/lib/checkr/report_test.rb index 222b8e3..f249a23 100644 --- a/test/lib/checkr/report_test.rb +++ b/test/lib/checkr/report_test.rb @@ -36,4 +36,16 @@ end end + describe '.update' do + let(:report) { Checkr::Report.update("5878551b3ee1eacae5a2c558", :package => 'driver_pro')} + + it "should return report object" do + report.must_be_instance_of(Checkr::Report) + end + + it "returns report object with updated parameters" do + report.id.must_equal("5878551b3ee1eacae5a2c558") + report.package.must_equal("driver_pro") + end + end end