Class: ApiKey

Inherits:
LogicalModel
  • Object
show all
Defined in:
app/models/api_key.rb

Constant Summary collapse

TIMEOUT =

milisecons

5500
PER_PAGE =
9999

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.check(key, params = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/api_key.rb', line 21

def self.check(key, params={})
  res = nil
  params = self.merge_key(params).merge({api_key: key})
  request = Typhoeus::Request.new("#{resource_uri}/check", params: params )

  request.on_complete do |response|
    if response.code >= 200 && response.code < 400
      log_ok(response)
      res = self.new.from_json(response.body)
    else
      log_failed(response)
    end
  end

  self.hydra.queue(request)
  self.hydra.run

  res
end

.find(id, params = {}) ⇒ Object



16
17
18
19
# File 'app/models/api_key.rb', line 16

def self.find(id, params={})
  Rails.logger.warn "ApiKey.find is deprecated. Use ApiKey.check instead"
  self.check(id, params)
end

Instance Method Details

#json_rootObject



41
42
43
# File 'app/models/api_key.rb', line 41

def json_root
  'api_key'
end