Class: Dadata::CleanClient
- Inherits:
-
ClientBase
- Object
- ClientBase
- Dadata::CleanClient
- Defined in:
- lib/dadata/client/clean.rb
Overview
Client for data cleaning and standardization operations
Constant Summary collapse
- BASE_URL =
'https://cleaner.dadata.ru/api/v1/'
Constants inherited from ClientBase
Dadata::ClientBase::ERRORS, Dadata::ClientBase::STATUS_ERRORS
Constants included from SensitiveData
SensitiveData::SENSITIVE_HEADERS
Instance Method Summary collapse
-
#clean(name, source) ⇒ Hash?
Clean and standardize a single value.
-
#clean_record(structure, record) ⇒ Hash?
Clean and standardize a composite record.
-
#initialize(token = Dadata.api_key, secret = Dadata.secret_key) ⇒ CleanClient
constructor
A new instance of CleanClient.
Methods inherited from ClientBase
Methods included from SensitiveData
#sanitize_headers, #sanitize_message
Constructor Details
#initialize(token = Dadata.api_key, secret = Dadata.secret_key) ⇒ CleanClient
Returns a new instance of CleanClient.
10 11 12 |
# File 'lib/dadata/client/clean.rb', line 10 def initialize(token = Dadata.api_key, secret = Dadata.secret_key) super(BASE_URL, token, secret) end |
Instance Method Details
#clean(name, source) ⇒ Hash?
Clean and standardize a single value
27 28 29 30 |
# File 'lib/dadata/client/clean.rb', line 27 def clean(name, source) response = submit("clean/#{name}", [source], :post) response&.first end |
#clean_record(structure, record) ⇒ Hash?
Clean and standardize a composite record
46 47 48 49 50 |
# File 'lib/dadata/client/clean.rb', line 46 def clean_record(structure, record) data = { structure:, data: [record] } response = submit('clean', data, :post) response&.dig('data', 0) end |