Class: DuoApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/duo-api/client.rb

Constant Summary collapse

ATTRIBUTES =
%w[
  integration_key
  secret_key
  app_secret
  hostname
]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
18
19
20
21
# File 'lib/duo-api/client.rb', line 13

def initialize(options = {})
  options.each do |key, value|
    if ATTRIBUTES.include?(key.to_s)
      instance_variable_set("@#{key}", value)
    else
      raise ArgumentError, "no attribute #{key}"
    end
  end
end

Instance Method Details

#get(path, options = {}) ⇒ Object



23
24
25
# File 'lib/duo-api/client.rb', line 23

def get(path, options = {})
  Request.request(self, path, { :method => "GET" }.merge(options))
end

#post(path, options = {}) ⇒ Object



27
28
29
# File 'lib/duo-api/client.rb', line 27

def post(path, options = {})
  Request.request(self, path, { :method => "POST" }.merge(options))
end

#sign(user_key) ⇒ Object



31
32
33
# File 'lib/duo-api/client.rb', line 31

def sign(user_key)
  signer.sign(user_key)
end

#verify(signed_response) ⇒ Object



35
36
37
# File 'lib/duo-api/client.rb', line 35

def verify(signed_response)
  signer.verify(signed_response)
end