dilisense_pep_client 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 273fac377fd26f38c2114fb2064c9be039ae46fd5c76208ae2a2f052d576a31b
4
+ data.tar.gz: a05d1cc25e0862acdba9d5cd23735dd83a835e9ba7a4f214f4a757b20623ce39
5
+ SHA512:
6
+ metadata.gz: 11845d5f7f5a7d727b6c8a189f6148dc7801cb9d274966e0204fe990f63f8e4367df338c9cfc861a055287498fc96d2557a0629c6a1e56999a93c1c54505407c
7
+ data.tar.gz: 88b14710b78f2b46a2e12a0a98d22238d29e7b0065b3e06e318eb5da00fa7f57ac2e5fdf0f1cb6e59c6c1304b6949b0587e913ad41c002e67be02a835fb32a3d
data/.env.example ADDED
@@ -0,0 +1,2 @@
1
+ # Copy this file to .env and add your actual API key
2
+ DILISENSE_API_KEY=your_api_key_here
data/CLAUDE.md ADDED
@@ -0,0 +1,141 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is a Ruby gem client library for the Dilisense Screening API, specifically for PEP (Politically Exposed Persons) screening. The gem is owned by Sorbeet Payments OU and licensed under MIT.
8
+
9
+ ## Development Setup
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ bundle install
14
+
15
+ # Copy environment file and add your API key
16
+ cp .env.example .env
17
+ # Edit .env and add your Dilisense API key
18
+ ```
19
+
20
+ ## Development Commands
21
+
22
+ ```bash
23
+ # Run tests
24
+ bundle exec rake test
25
+
26
+ # Run linter
27
+ bundle exec rubocop
28
+
29
+ # Run both tests and linting
30
+ bundle exec rake ci
31
+
32
+ # Build gem
33
+ gem build dilisense_pep_client.gemspec
34
+
35
+ # Console for testing
36
+ bundle console
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ```ruby
42
+ require 'dilisense_pep_client'
43
+
44
+ # Configure with API key (or set DILISENSE_API_KEY environment variable)
45
+ DilisensePepClient.configure do |config|
46
+ config.api_key = 'your_api_key'
47
+ end
48
+
49
+ # Check individual - returns array with one element per unique person
50
+ result = DilisensePepClient.check_individual(
51
+ names: "Mari Kask",
52
+ dob: "15/03/1985",
53
+ gender: "female"
54
+ )
55
+ # => [] (empty array if no matches)
56
+
57
+ result = DilisensePepClient.check_individual(names: "Donald Trump")
58
+ # => [
59
+ # {
60
+ # name: "Donald Trump Jr.",
61
+ # source_type: "PEP",
62
+ # pep_type: "RELATIVES_AND_CLOSE_ASSOCIATES",
63
+ # sources: ["dilisense_pep"],
64
+ # total_records: 1
65
+ # },
66
+ # {
67
+ # name: "Donald Trump",
68
+ # source_type: "PEP",
69
+ # pep_type: "POLITICIAN",
70
+ # sources: ["dilisense_pep"],
71
+ # total_records: 2
72
+ # }
73
+ # ]
74
+
75
+ # Check entity - also returns array with one element per unique entity
76
+ result = DilisensePepClient.check_entity(names: "ACME Corp")
77
+ # => [] (empty array if no matches)
78
+
79
+ result = DilisensePepClient.check_entity(names: "Gazprom")
80
+ # => [
81
+ # {
82
+ # name: "Gazprom",
83
+ # source_type: "SANCTION",
84
+ # jurisdiction: ["RU"],
85
+ # address: ["Russia"],
86
+ # sanction_details: ["Subject to sanctions"],
87
+ # sources: ["us_department_of_treasury_sdn"],
88
+ # total_records: 1
89
+ # }
90
+ # ]
91
+
92
+ # Entity with fuzzy search
93
+ result = DilisensePepClient.check_entity(names: "Gasprom", fuzzy_search: 1)
94
+ ```
95
+
96
+ ## Response Format
97
+
98
+ Both `check_individual` and `check_entity` return an **array** where each element represents a unique person/entity:
99
+
100
+ ### Individual Response
101
+ ```ruby
102
+ [
103
+ {
104
+ name: "Person Name", # Primary name
105
+ source_type: "PEP", # PEP, SANCTION, CRIMINAL
106
+ pep_type: "POLITICIAN", # Only for PEP records
107
+ gender: "MALE", # MALE, FEMALE, UNKNOWN
108
+ date_of_birth: ["07/10/1952"], # Array of DOBs
109
+ citizenship: ["RU"], # Array of citizenships
110
+ sources: ["source1", "source2"], # All sources where found
111
+ total_records: 16, # Number of raw records
112
+ raw_records: [...] # All original API records
113
+ }
114
+ ]
115
+ ```
116
+
117
+ ### Entity Response
118
+ ```ruby
119
+ [
120
+ {
121
+ name: "Company Name", # Primary entity name
122
+ source_type: "SANCTION", # PEP, SANCTION, CRIMINAL
123
+ pep_type: "STATE_OWNED_ENTERPRISE", # Only for PEP entities
124
+ jurisdiction: ["RU"], # Array of jurisdictions
125
+ address: ["Moscow, Russia"], # Array of addresses
126
+ sanction_details: ["Reason"], # Array of sanction details
127
+ sources: ["source1", "source2"], # All sources where found
128
+ total_records: 3, # Number of raw records
129
+ raw_records: [...] # All original API records
130
+ }
131
+ ]
132
+ ```
133
+
134
+ ## Implementation Notes
135
+
136
+ - API key authentication using `x-api-key` header
137
+ - GET requests with query parameters
138
+ - JSON responses with timestamp, total_hits, and found_records
139
+ - Error handling for 400, 401, 403, 500 status codes
140
+ - Uses Faraday for HTTP requests
141
+ - Minimal dependencies (only Faraday)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sorbeet Payments OU
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,98 @@
1
+ # Makefile for dilisense_pep_client Ruby gem
2
+ #
3
+ # This Makefile provides convenient commands for development, testing, and maintenance
4
+ # of the Dilisense PEP/sanctions screening Ruby client library.
5
+ #
6
+ # The gem includes both unit tests (no external dependencies) and integration tests
7
+ # that make real API calls to the Dilisense service. API key must be configured
8
+ # in .env file for integration tests to work properly.
9
+
10
+ .PHONY: test individual_test unit_test test_fuzzy entity_test install lint ci clean help
11
+
12
+ # Default target - show available commands
13
+ help:
14
+ @echo "Dilisense PEP Client - Available Make Commands:"
15
+ @echo ""
16
+ @echo "Testing Commands:"
17
+ @echo " test - Run all tests (unit + integration with 2-second delays)"
18
+ @echo " individual_test - Run individual screening tests with real API calls"
19
+ @echo " unit_test - Run unit tests only (no external API calls required)"
20
+ @echo " test_fuzzy - Run fuzzy search integration tests with real API calls"
21
+ @echo " entity_test - Run entity screening tests with real API calls"
22
+ @echo ""
23
+ @echo "Development Commands:"
24
+ @echo " install - Install Ruby gem dependencies via Bundler"
25
+ @echo " lint - Run RuboCop code style linter and formatter"
26
+ @echo " ci - Run continuous integration suite (tests + linting)"
27
+ @echo " clean - Remove generated coverage reports and temporary files"
28
+ @echo ""
29
+ @echo "Requirements:"
30
+ @echo " - Ruby 2.7+ with Bundler installed"
31
+ @echo " - Valid Dilisense API key in .env file for integration tests"
32
+ @echo " - Internet connection for API-based tests"
33
+
34
+ # Install Ruby gem dependencies via Bundler
35
+ # This will install all gems specified in the Gemfile including development dependencies
36
+ install:
37
+ @echo "Installing Ruby gem dependencies..."
38
+ bundle install
39
+ @echo "Dependencies installed successfully!"
40
+
41
+ # Run all tests with rate limit protection (2-second delays between tests)
42
+ # Includes both unit tests and integration tests with real API calls
43
+ test:
44
+ @echo "Running comprehensive test suite with rate limiting..."
45
+ bundle exec rake test
46
+
47
+ # Run individual screening integration tests with real API calls
48
+ # Tests person-based PEP screening functionality against live Dilisense API
49
+ individual_test:
50
+ @echo "Running individual screening integration tests..."
51
+ @echo "Testing names: Vladimir Putin, Xi Jinping, Joe Biden..."
52
+ bundle exec ruby -Ilib:test test/test_integration.rb
53
+ @echo "Individual screening tests completed!"
54
+
55
+ # Run unit tests only - no external API calls required
56
+ # These tests use mocks and stubs to verify internal logic without network dependencies
57
+ unit_test:
58
+ @echo "Running unit tests (no API calls)..."
59
+ bundle exec ruby -Ilib:test test/test_client.rb test/test_dilisense_pep_client.rb
60
+ @echo "Unit tests completed!"
61
+
62
+ # Run fuzzy search integration tests with real API calls
63
+ # Tests fuzzy matching capabilities for names with variations and typos
64
+ test_fuzzy:
65
+ @echo "Running fuzzy search integration tests..."
66
+ @echo "Testing fuzzy matching for: Vladmir Putin (typo), Xi Jin Ping (spacing)..."
67
+ bundle exec ruby -Ilib:test test/test_fuzzy.rb
68
+ @echo "Fuzzy search tests completed!"
69
+
70
+ # Run entity screening integration tests with real API calls
71
+ # Tests company/organization screening against sanctions and watchlists
72
+ entity_test:
73
+ @echo "Running entity screening integration tests..."
74
+ @echo "Testing entities: Bank Rossiya, Gazprom, sanctioned organizations..."
75
+ bundle exec ruby -Ilib:test test/test_entity.rb
76
+ @echo "Entity screening tests completed!"
77
+
78
+ # Run RuboCop linter to check code style and formatting
79
+ # Enforces Ruby style guide and identifies potential issues
80
+ lint:
81
+ @echo "Running RuboCop code style linter..."
82
+ bundle exec rubocop
83
+ @echo "Linting completed!"
84
+
85
+ # Run continuous integration suite (tests + linting)
86
+ # Comprehensive check suitable for CI/CD pipelines
87
+ ci:
88
+ @echo "Running CI suite (tests + linting)..."
89
+ bundle exec rake ci
90
+ @echo "CI suite completed!"
91
+
92
+ # Clean generated files and coverage reports
93
+ # Removes temporary files created during testing and development
94
+ clean:
95
+ @echo "Cleaning generated files..."
96
+ rm -rf coverage/
97
+ rm -rf tmp/
98
+ @echo "Cleanup completed!"