Class: Dadata::ProfileClient
- Inherits:
-
ClientBase
- Object
- ClientBase
- Dadata::ProfileClient
- Defined in:
- lib/dadata/client/profile.rb
Overview
Client for managing DaData subscriber profile
Constant Summary collapse
- BASE_URL =
'https://dadata.ru/api/v2/'
Constants inherited from ClientBase
ClientBase::ERRORS, ClientBase::STATUS_ERRORS
Constants included from SensitiveData
SensitiveData::SENSITIVE_HEADERS
Instance Method Summary collapse
-
#balance ⇒ Numeric?
Get current balance.
-
#daily_stats(date = nil) ⇒ Hash?
Get daily statistics.
-
#initialize(token = Dadata.api_key, secret = Dadata.secret_key) ⇒ ProfileClient
constructor
A new instance of ProfileClient.
-
#versions ⇒ Hash?
Get API versions.
Methods inherited from ClientBase
Methods included from SensitiveData
#sanitize_headers, #sanitize_message
Constructor Details
#initialize(token = Dadata.api_key, secret = Dadata.secret_key) ⇒ ProfileClient
Returns a new instance of ProfileClient.
11 12 13 |
# File 'lib/dadata/client/profile.rb', line 11 def initialize(token = Dadata.api_key, secret = Dadata.secret_key) super(BASE_URL, token, secret) end |
Instance Method Details
#balance ⇒ Numeric?
Get current balance
18 19 20 21 |
# File 'lib/dadata/client/profile.rb', line 18 def balance response = submit('profile/balance', {}, :get) response&.fetch('balance', nil) end |
#daily_stats(date = nil) ⇒ Hash?
Get daily statistics
27 28 29 30 |
# File 'lib/dadata/client/profile.rb', line 27 def daily_stats(date = nil) date = date.nil? ? Date.today : handle_date(date) submit('stat/daily', { date: date.iso8601 }, :get) end |
#versions ⇒ Hash?
Get API versions
35 36 37 |
# File 'lib/dadata/client/profile.rb', line 35 def versions submit('version', {}, :get) end |