Class: Datadome::Client
- Inherits:
-
Object
- Object
- Datadome::Client
- Defined in:
- lib/datadome/client.rb
Constant Summary collapse
- OPEN_TIMEOUT =
1- TIMEOUT =
3
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.base_url ⇒ Object
14 15 16 |
# File 'lib/datadome/client.rb', line 14 def base_url "https://#{Datadome.configuration.api_server}/" end |
.default_params ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/datadome/client.rb', line 18 def default_params { "Key" => Datadome.configuration.api_key, "RequestModuleName" => "DataDome Ruby Gem", "ModuleVersion" => ::Datadome::VERSION, "ServerName" => hostname, } end |
.hostname ⇒ Object
27 28 29 |
# File 'lib/datadome/client.rb', line 27 def hostname Socket.gethostname end |
Instance Method Details
#check ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/datadome/client.rb', line 33 def check response = connection.get do |req| req.url("check") end response end |
#validate_request(data) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/datadome/client.rb', line 42 def validate_request(data) data = data.merge(self.class.default_params) response = connection.post do |req| req.url("validate-request") req.headers["User-Agent"] = "DataDome" req.body = data end ValidationResponse.from_faraday_response(response) rescue Faraday::Error::ConnectionFailed, Faraday::Error::TimeoutError => e Datadome.logger.warn("Datadome: Timeout #{e}") ValidationResponse.pass end |