Sha256: ddae24ced704031bf5957e213caf9f0be8686737c4ab432df69b492b6c5446a8
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
module Ahub class Question extend Ahub::APIHelpers include Ahub::ClassHelpers 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 attr_accessor :title, :body, :body_as_html, :author attr_reader :space_id, :answerCount def initialize(attrs) @id = attrs[:id] @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 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 def url "#{self.class.base_url}/#{id}.json" if id end def to_s url end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ahub-0.1.17 | lib/ahub/question.rb |