Class: RoQua::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/roqua/site.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url, username, password) ⇒ Site

Returns a new instance of Site.



7
8
9
10
11
# File 'lib/roqua/site.rb', line 7

def initialize(base_url, username, password)
  @url = Addressable::URI.parse(base_url)
  @url.user = username
  @url.password = password
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



5
6
7
# File 'lib/roqua/site.rb', line 5

def password
  @password
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/roqua/site.rb', line 3

def url
  @url
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/roqua/site.rb', line 4

def username
  @username
end

Instance Method Details

#answers(options = {}) ⇒ Object



17
18
19
20
21
# File 'lib/roqua/site.rb', line 17

def answers(options = {})
  response = RestClient.get(url.to_s + "/patients/#{options[:patient_id]}/questionnaires/#{options[:questionnaire_key]}/answers")
  json = JSON.parse(response)
  json.map { |item| Answer.new(item) }
end