Sha256: 2cb52980868f57337b9549696e9c7f97b6455b459e13aed4989e7156ae859bfe

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# show

class Quandora::Question < Quandora::Request
  def detail(question_id)
    @api = "q/"
    show("#{question_id}")
  end

  def view(question_id, args = {})
    @api = "q/"
    show("#{question_id}/view")
  end

  def mlt(question_id, args = {})
    @api = "q/"
    show("#{question_id}/mlt")
  end

  def answer(question_id, args)
    args = args.stringify_keys

    body = {
      "type": "post-answer",
      "data": {
        "content": args["content"],
        "contentType": args["content_type"] || "markdown"
      }
    }
    resp = @conn.post("q/#{question_id}/answer") do |req|
      req.body = body.to_json
      req.headers['Content-Type'] = 'application/json'
    end
  end

  def vote(question_id, args)
    args = args.stringify_keys

    body = {
      "type": "boolean",
      "data": args["vote"]
    }

    resp = @conn.post("q/#{question_id}/vote") do |req|
      req.body = body.to_json
      req.headers['Content-Type'] = 'application/json'
    end
  end

  def comment(question_id)
    Quandora::Comment.new(@conn, "q", question_id)
  end

  def tag(answer_id)
    Quandora::Tag.new(@conn, "q", answer_id)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quandora-0.3.0 lib/quandora/question.rb