Sha256: fe068d0c548b896e6e924bae216aecdcadda619c74af4c096cf313699627fbd4

Contents?: true

Size: 1.99 KB

Versions: 4

Compression:

Stored size: 1.99 KB

Contents

module Troo
  module Remote
    class Card
      include Virtus.model(finalize: false)
      include Troo::RemoteModelHelpers

      attribute :id
      attribute :badges
      attribute :checkItemStates
      attribute :closed,                Boolean
      attribute :dateLastActivity
      attribute :desc
      attribute :descData
      attribute :due
      attribute :idBoard
      attribute :idChecklists
      attribute :idList
      attribute :idMembers
      attribute :idShort
      attribute :idAttachmentCover
      attribute :manualCoverAttachment
      attribute :labels
      attribute :name
      attribute :pos
      attribute :shortUrl
      attribute :url
      attribute :actions,               Array[Troo::Remote::Comment]

      class << self
        # @return [Hash]
        def remote_options
          { mode: :card }
        end

        # @return [Hash]
        def by_board_id
          {
            endpoint: :cards_by_board_id,
            query:    { filter: :open }
          }
        end

        # @return [Hash]
        def by_list_id
          {
            endpoint: :cards_by_list_id,
            query:    { filter: :open }
          }
        end

        # @return [Hash]
        def by_card_id
          {
            endpoint: :card_by_id,
            query:    { actions: :commentCard }
          }
        end
      end

      # @return [Array]
      def associations
        [:actions]
      end

      # @return []
      def local_model
        Troo::Card
      end

      # @return [Hash]
      def adapted
        {
          short_id:            idShort,
          name:                name,
          desc:                desc,
          url:                 url,
          position:            pos,
          last_activity_date:  dateLastActivity,
          closed:              closed,
          external_board_id:   idBoard,
          external_list_id:    idList,
          external_id:         id,
          external_member_ids: idMembers
        }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
troo-0.0.14 lib/troo/remote/card.rb
troo-0.0.13 lib/troo/remote/card.rb
troo-0.0.12 lib/troo/remote/card.rb
troo-0.0.11 lib/troo/remote/card.rb