Class: Ahub::Question
- Inherits:
-
Object
- Object
- Ahub::Question
- Extended by:
- APIHelpers
- Includes:
- ClassHelpers
- Defined in:
- lib/ahub/question.rb
Instance Attribute Summary collapse
-
#answerCount ⇒ Object
readonly
Returns the value of attribute answerCount.
-
#author ⇒ Object
Returns the value of attribute author.
-
#body ⇒ Object
Returns the value of attribute body.
-
#body_as_html ⇒ Object
Returns the value of attribute body_as_html.
-
#space_id ⇒ Object
readonly
Returns the value of attribute space_id.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Question
constructor
A new instance of Question.
- #move(space_id:) ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
Methods included from APIHelpers
admin_headers, base_url, find, find_all, headers, object_id_from_response
Methods included from ClassHelpers
Constructor Details
#initialize(attrs) ⇒ Question
Returns a new instance of Question.
20 21 22 23 24 25 26 27 28 |
# File 'lib/ahub/question.rb', line 20 def initialize(attrs) @answer_ids = attrs[:answers] @answerCount = attrs[:answerCount] @body = attrs[:body] @body_as_html = attrs[:bodyAsHTML] @space_id = attrs[:primaryContainerId] @title = attrs[:title] @topics = attrs[:topics] end |
Instance Attribute Details
#answerCount ⇒ Object (readonly)
Returns the value of attribute answerCount.
18 19 20 |
# File 'lib/ahub/question.rb', line 18 def answerCount @answerCount end |
#author ⇒ Object
Returns the value of attribute author.
17 18 19 |
# File 'lib/ahub/question.rb', line 17 def @author end |
#body ⇒ Object
Returns the value of attribute body.
17 18 19 |
# File 'lib/ahub/question.rb', line 17 def body @body end |
#body_as_html ⇒ Object
Returns the value of attribute body_as_html.
17 18 19 |
# File 'lib/ahub/question.rb', line 17 def body_as_html @body_as_html end |
#space_id ⇒ Object (readonly)
Returns the value of attribute space_id.
18 19 20 |
# File 'lib/ahub/question.rb', line 18 def space_id @space_id end |
#title ⇒ Object
Returns the value of attribute title.
17 18 19 |
# File 'lib/ahub/question.rb', line 17 def title @title end |
Class Method Details
.create(title:, body:, topics:, space_id: nil, username:, password:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ahub/question.rb', line 6 def self.create(title:, body:, topics:, space_id: nil, username:, password:) url = "#{base_url}.json" payload = {title: title, body: body, topics: topics} payload[:spaceId] = space_id if space_id user_headers = headers(username:username, password:password) make_post_call(url: url, payload: payload, headers: user_headers) end |
Instance Method Details
#move(space_id:) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/ahub/question.rb', line 30 def move(space_id:) raise Exception("No Question Id") unless id move_url = "#{self.class.base_url}/#{id}/move.json?space=#{space_id}" RestClient.put("#{url}", self.class.admin_headers) end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/ahub/question.rb', line 41 def to_s url end |
#url ⇒ Object
37 38 39 |
# File 'lib/ahub/question.rb', line 37 def url "#{self.class.base_url}/#{id}.json" if id end |