Sha256: 114a8afa6ba6f9b9b5236bbfa0aff7cee0c7f2122481488dbc9147c3e0f0d216

Contents?: true

Size: 615 Bytes

Versions: 1

Compression:

Stored size: 615 Bytes

Contents

module Ahub
  class Answer
    extend Ahub::APIHelpers
    include Ahub::ClassHelpers

    def self.create(question_id:, body:, username:, password:)
      url = "#{Ahub::DOMAIN}/services/v2/question/#{question_id}/answer.json"

      make_post_call(url: url, payload: {body: body}, headers: headers(username: username, password: password))
    end

    attr_reader :body, :body_as_html, :author

    def initialize(attrs)
      @id = attrs[:id]
      @body = attrs[:body]
      @body_as_html = attrs[:bodyAsHTML]
      @author = Ahub::User.new(attrs[:author])
    end

    def user
      @author
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ahub-0.1.17 lib/ahub/answer.rb