Sha256: d7567f2e084af3a55c65c06ad5530bb0b4cb412add039dcf05fa37b8d0327911

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

# encoding: utf-8
module Jiralicious
  class Issue
    class Comment < Jiralicious::Base

      attr_accessor :jira_key

      def initialize(decoded_json = nil, default = nil, &blk)
        if (decoded_json != nil)
          properties_from_hash(decoded_json)
          super(decoded_json)
          parse!(decoded_json)
        end
      end

      class << self
        def find_by_key(key, options = {})
          response = fetch({:parent => parent_name, :parent_key => key})
          a = new(response)
          a.jira_key = key
          return a
        end

        def find_by_key_and_id(key, id, options = {})
          response = fetch({:parent => parent_name, :parent_key => key, :key => id})
          a = new(response)
          a.jira_key = key
          return a
        end

        def add(comment, key)
          fetch({:method => :post, :body => comment, :parent => parent_name, :parent_key => key})
        end

        def edit(comment, key, id)
          fetch({:method => :put, :key => id, :body => comment, :parent => parent_name, :parent_key => key})
        end

        def remove(key, id)
          fetch({:method => :delete, :body_to_params => true, :key => id, :parent => parent_name, :parent_key => key})

        end
      end

      def find_by_id(id, options = {})
        self.class.find_by_key_and_id(@jira_key, id)
      end

      def add(comment)
        self.class.add(comment, @jira_key)
      end

      def edit(comment)
        self.class.edit(comment, @jira_key, self.id)
      end

      def remove(id = self.id)
        self.class.remove(@jira_key, id)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jiralicious-0.2.0 lib/jiralicious/issue/comment.rb