lib/ahub/answer.rb in ahub-0.0.3 vs lib/ahub/answer.rb in ahub-0.0.5
- old
+ new
@@ -3,25 +3,25 @@
require 'ahub/modules/api_helpers'
module Ahub
class Answer
extend Ahub::APIHelpers
- def self.find(id)
- end
- def self.create(question_id:, body:)
- data = {
- body: body
- }
+ def self.create(question_id:, body:, username:, password:)
+ data = {body: body}
- url = "http://localhost:8888/services/v2/question/#{question_id}/answer.json"
+ url = "#{Ahub::DOMAIN}/services/v2/question/#{question_id}/answer.json"
- JSON.parse RestClient.post(url, data.to_json, headers)
+ auth_headers = headers(username: username, password: password)
+
+ OpenStruct.new(
+ JSON.parse(
+ RestClient.post(url, data.to_json, auth_headers),
+ symbolize_names: true
+ )
+ )
rescue => e
{error: e.message}
end
- def self.get_all_by_question(question_id:)
-
- end
end
end