Module: EasyCompliance::Client
- Defined in:
- lib/easy_compliance/client.rb
Overview
client for easycompliance.de/schnittstellen/api/
Defined Under Namespace
Classes: Error
Constant Summary collapse
- HEADERS =
{ 'Content-Type': 'application/x-www-form-urlencoded', }
Class Method Summary collapse
-
.check_now(record:, value:) ⇒ EasyCompliance::Result
check if record is currently on a sanctions list.
-
.fetch_list ⇒ EasyCompliance::Result
get matches of last 24 hours.
- .post(**body) ⇒ EasyCompliance::Result
-
.submit(record:, value:) ⇒ EasyCompliance::Result
like ‘#check_now`, but also adds to list for future automatic checks.
Class Method Details
.check_now(record:, value:) ⇒ EasyCompliance::Result
check if record is currently on a sanctions list
13 14 15 16 |
# File 'lib/easy_compliance/client.rb', line 13 def check_now(record:, value:) ref = EasyCompliance::Ref.for_record(record) post(method: 1, ref: ref, name: value) end |
.fetch_list ⇒ EasyCompliance::Result
get matches of last 24 hours
27 28 29 |
# File 'lib/easy_compliance/client.rb', line 27 def fetch_list post(method: 3) end |
.post(**body) ⇒ EasyCompliance::Result
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/easy_compliance/client.rb', line 36 def post(**body) url = EasyCompliance.api_url or raise Error, "must set api_url" body[:api_key] = EasyCompliance.api_key or raise Error, "must set api_key" res = Excon.post(url, body: URI.encode_www_form(body), headers: HEADERS) res.status < 300 or raise Error, "#{res.status}: #{res.body}" EasyCompliance::Result.new(status: res.status, body: res.body) rescue Excon::Error, OpenSSL::OpenSSLError => e raise Error, "Network error: #{e.class.name} - #{e.message}" end |
.submit(record:, value:) ⇒ EasyCompliance::Result
like ‘#check_now`, but also adds to list for future automatic checks
20 21 22 23 |
# File 'lib/easy_compliance/client.rb', line 20 def submit(record:, value:) ref = EasyCompliance::Ref.for_record(record) post(method: 2, ref: ref, name: value) end |