diff --git a/lib/factiva.rb b/lib/factiva.rb index 3ee202a..0e833f8 100644 --- a/lib/factiva.rb +++ b/lib/factiva.rb @@ -1,7 +1,6 @@ Dir[File.join(__dir__, "factiva", "*.rb")].each { |file| require file } module Factiva - REQUEST_API_ACCOUNT = "request_api_account" MONITORING_API_ACCOUNT = "monitoring_api_account" diff --git a/lib/factiva/monitoring.rb b/lib/factiva/monitoring.rb index 7105505..d771c1f 100644 --- a/lib/factiva/monitoring.rb +++ b/lib/factiva/monitoring.rb @@ -3,9 +3,6 @@ module Factiva class Monitoring - private_class_method :new - attr_reader :client - COUNTRY_IDS = { "ES" => "SPAIN", "FR" => "FRA", @@ -13,6 +10,9 @@ class Monitoring "PT" => "PORL", }.freeze + private_class_method :new + attr_reader :client + def self.create_case(**args) instance.create_case(**args) end @@ -71,9 +71,9 @@ def initialize(stubbed_create_case, stubbed_get_matches, stubbed_log_decision ) - @stubbed_create_case = stubbed_create_case - @stubbed_create_association = stubbed_create_association - @stubbed_add_association_to_case = stubbed_add_association_to_case + @stubbed_create_case = stubbed_create_case + @stubbed_create_association = stubbed_create_association + @stubbed_add_association_to_case = stubbed_add_association_to_case @stubbed_get_matches = stubbed_get_matches @stubbed_log_decision = stubbed_log_decision end @@ -111,7 +111,7 @@ def create_case(case_body_payload = nil) def create_association(first_name:, last_name:, birth_year:, external_id:, nin:, country_code:) params = { json: association_body( - first_name, + first_name, last_name, birth_year, external_id, @@ -125,7 +125,7 @@ def create_association(first_name:, last_name:, birth_year:, external_id:, nin:, def add_association_to_case(case_id:, association_id:) params = { json: case_association_body( - association_id, + association_id, ) } @@ -138,7 +138,7 @@ def get_matches(case_id:) def log_decision(case_id:, match_id:, comment:, state:, risk_rating:) params = { json: log_decision_body( - comment, state, risk_rating, + comment, state, risk_rating, ) } diff --git a/spec/factiva/monitoring_spec.rb b/spec/factiva/monitoring_spec.rb index 56e64e5..afa4a20 100644 --- a/spec/factiva/monitoring_spec.rb +++ b/spec/factiva/monitoring_spec.rb @@ -86,7 +86,8 @@ module Factiva } } - context "when there isn't matches in the Case", vcr: "monitoring/no_matches" do # this VCR was recorded when there wasn't any match + # this VCR was recorded when there wasn't any match + context "when there isn't matches in the Case", vcr: "monitoring/no_matches" do let(:case_id) { "91473caa-9eb8-4eb1-891d-bde3d7c80cdd" } it "authenticates and doesn't get matches" do @@ -96,7 +97,6 @@ module Factiva end context "when there are matches in the Case", vcr: "monitoring/matches" do - let(:case_id) { "296373b3-80ee-4fb7-9f2e-b43604051c0b" } it "authenticates and returns 2 matches: 1 valid and 1 invalid" do @@ -106,23 +106,23 @@ module Factiva invalid_match = { "peid" => "1003410", "type" => "RELATIONSHIP", - "variation" => {"structural" => false, "linguistic" => false, "non_linguistic" => false}, + "variation" => { "structural" => false, "linguistic" => false, "non_linguistic" => false }, "title" => "OFAC - Principal Significant Foreign Narcotics Trafficker List", "match_id" => "239b4a188aff307a328984b0129dbb3a1fd5a9e9385e664fb3091fcce67ecd17", "match_name" => "Maria Remedios Garcia Albert", "match_type" => "PRECISE", - "percentage_match" =>1.0, + "percentage_match" => 1.0, "subscription_name" => "Maria Remedios Garcia Albert", - "boosting_events" =>[], + "boosting_events" => [], "icon_hints" => ["SAN-PERSON", "SI-PERSON"], "primary_country" => "SPAIN", "is_score_boosted" => false, - "current_state" => {"timestamp" => "2022-06-22T07:41:53", "state" => "OPEN"}, - "birthdates" => [{"day" => 17, "year" => 1951, "month" => 2}], + "current_state" => { "timestamp" => "2022-06-22T07:41:53", "state" => "OPEN" }, + "birthdates" => [{ "day" => 17, "year" => 1951, "month" => 2 }], "gender" => "FEMALE", "is_deceased" => false, "match_date" => "2022-06-22T07:41:53", - "primary_name" => {"name_type" => "PRIMARY", "first_name" => "Maria Remedios", "last_name" => "Garcia Albert"}, + "primary_name" => { "name_type" => "PRIMARY", "first_name" => "Maria Remedios", "last_name" => "Garcia Albert" }, "has_alerts" => false, "is_match_valid" => false, "match_invalid_date" => "2022-06-22T07:41:53.349", @@ -132,7 +132,7 @@ module Factiva valid_match = { "peid" => "1003410", "type" => "RELATIONSHIP", - "variation" => {"structural"=>false, "linguistic"=>false, "non_linguistic"=>false}, + "variation" => { "structural" => false, "linguistic" => false, "non_linguistic" => false }, "title" => "OFAC - Principal Significant Foreign Narcotics Trafficker List", "match_id" => "5e7a91388deea1e1368937aaa00c69635890f51e964909eb1f4daccf2ee69ca5", "match_name" => "Maria Remedios Garcia Albert", @@ -143,12 +143,12 @@ module Factiva "icon_hints" => ["SAN-PERSON", "SI-PERSON"], "primary_country" => "SPAIN", "is_score_boosted" => false, - "current_state" => {"timestamp" => "2022-06-22T07:41:54", "state" => "OPEN"}, - "birthdates" => [{"day"=>17, "year"=>1951, "month"=>2}], + "current_state" => { "timestamp" => "2022-06-22T07:41:54", "state" => "OPEN" }, + "birthdates" => [{ "day" => 17, "year" => 1951, "month" => 2 }], "gender" => "FEMALE", "is_deceased" => false, "match_date" => "2022-06-22T07:41:54", - "primary_name" => {"name_type" => "PRIMARY", "first_name" => "Maria Remedios", "last_name" => "Garcia Albert"}, + "primary_name" => { "name_type" => "PRIMARY", "first_name" => "Maria Remedios", "last_name" => "Garcia Albert" }, "has_alerts" => true, "is_match_valid" => true, }.freeze @@ -156,7 +156,8 @@ module Factiva expect(result["data"][0]["attributes"]["external_id"]).to eq("id-XXXXXXX") expect(result["data"][0]["attributes"]["matches"][0]["subscription_name"]).to eq("Maria Remedios Garcia Albert") expect(result["data"][0]["attributes"]["matches"][0]["is_match_valid"]).to be_falsey - expect(result["data"][0]["attributes"]["matches"][0]["match_invalid_reason"]).to eq "Match excluded by filter: year_of_birth" + expect(result["data"][0]["attributes"]["matches"][0]["match_invalid_reason"]) + .to eq "Match excluded by filter: year_of_birth" expect(result["data"][0]["attributes"]["matches"][0]).to eq(invalid_match) expect(result["data"][1]["attributes"]["external_id"]).to eq("id1234") @@ -193,7 +194,8 @@ module Factiva it "authenticates and Logs a decision to a Match" do res = subject.log_decision(**sample_data) - expect(res["data"]["attributes"]["current_state"]).to eq({"timestamp"=>"2022-06-21T10:04:37.645", "comment"=>"False positive", "state"=>"CLEARED", "risk_rating"=>1}) + expect(res["data"]["attributes"]["current_state"]).to eq({ "timestamp" => "2022-06-21T10:04:37.645", +"comment" => "False positive", "state" => "CLEARED", "risk_rating" => 1 }) end end end diff --git a/spec/support/vcr_setup.rb b/spec/support/vcr_setup.rb index 20aaac4..80c8c2f 100644 --- a/spec/support/vcr_setup.rb +++ b/spec/support/vcr_setup.rb @@ -13,5 +13,6 @@ c.filter_sensitive_data("") { URI.encode_www_form_component(Factiva.configuration.username) } c.filter_sensitive_data("") { Factiva.configuration(Factiva::MONITORING_API_ACCOUNT).client_id } c.filter_sensitive_data("") { Factiva.configuration(Factiva::MONITORING_API_ACCOUNT).password } - c.filter_sensitive_data("") { URI.encode_www_form_component(Factiva.configuration(Factiva::MONITORING_API_ACCOUNT).username) } + c.filter_sensitive_data("") { + URI.encode_www_form_component(Factiva.configuration(Factiva::MONITORING_API_ACCOUNT).username) } end