# frozen_string_literal: true

module Api
  module V1
    class ActivityResource < BaseResource
      before_create do
        @model.owner = context[:current_user]
      end

      has_one :owner, class_name: 'Member', always_include_linkage_data: true
      has_one :garden, always_include_linkage_data: true
      has_one :planting, always_include_linkage_data: true

      attribute :name
      attribute :description
      attribute :category
      attribute :finished
      attribute :due_date

      filter :owner
      filter :owner_id
      filter :garden
      filter :garden_id
      filter :planting
      filter :planting_id
      filter :category
    end
  end
end
