Class: Ahub::Question

Inherits:
Object
  • Object
show all
Includes:
APIResource
Defined in:
lib/ahub/question.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIResource

#destroy, #initialize, #update

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



16
17
18
# File 'lib/ahub/question.rb', line 16

def body
  @body
end

#body_as_htmlObject

Returns the value of attribute body_as_html.



16
17
18
# File 'lib/ahub/question.rb', line 16

def body_as_html
  @body_as_html
end

#titleObject

Returns the value of attribute title.



16
17
18
# File 'lib/ahub/question.rb', line 16

def title
  @title
end

Class Method Details

.create(title:, body:, topics:, space_id: nil, username:, password:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/ahub/question.rb', line 5

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)

  create_resource(url: url, payload: payload, headers: user_headers)
end

Instance Method Details

#move(space_id:) ⇒ Object



22
23
24
25
26
27
# File 'lib/ahub/question.rb', line 22

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_sObject



33
34
35
# File 'lib/ahub/question.rb', line 33

def to_s
  url
end

#urlObject



29
30
31
# File 'lib/ahub/question.rb', line 29

def url
  "#{self.class.base_url}/#{id}.json" if id
end

#userObject



18
19
20
# File 'lib/ahub/question.rb', line 18

def user
  @author
end