Sha256: ab8c2ad1db7818b77a8b53f48c9a2419f4bb04179399f74dcf0a2d907593c184

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

module Ahub
  class Question
    include Ahub::APIResource

    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

    attr_accessor :title, :body, :body_as_html

    def user
      @author
    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.4.0 lib/ahub/question.rb