Sha256: 31817a1f7990f383defdd19f5c48c5b736e5c24799a0e0db947b4b524a4c3ba8

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module Dimelo::CCP
  class Answer < Dimelo::CCP::API::Model
    include ::Dimelo::CCP::API::Common::Publishable

    path 'questions/%{question_id}/answers/%{id}'

    attributes  :id, :body, :body_format, :flow_state, :user_id, :permalink,
                :attachments_count, :comments_count,
                :created_at, :updated_at, :question_id, :ipaddr, :question_flow_state

    submit_attributes :body, :body_format, :user_id, :question_id, :created_at

    belongs_to :user
    belongs_to :question

    has_many :answer_attachments

    def admin_stamp
      path = "#{compute_path(attributes)}/admin_stamp"
      response = client.transport(:post, path)
      self.attributes = Dimelo::CCP::API.decode_json(response)
      errors.empty?
    end

    def author_stamp
      path = "#{compute_path(attributes)}/author_stamp"
      response = client.transport(:post, path)
      self.attributes = Dimelo::CCP::API.decode_json(response)
      errors.empty?
    end

    def unstamp
      path = "#{compute_path(attributes)}/stamp"
      response = client.transport(:delete, path)
      self.attributes = Dimelo::CCP::API.decode_json(response)
      errors.empty?
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dimelo_ccp_api-0.5.0 lib/dimelo/ccp/api/model/answer.rb
dimelo_ccp_api-0.4.4 lib/dimelo/ccp/api/model/answer.rb
dimelo_ccp_api-0.4.3 lib/dimelo/ccp/api/model/answer.rb
dimelo_ccp_api-0.4.2 lib/dimelo/ccp/api/model/answer.rb