Sha256: 4428fd9b32aea30fe2af5646a0584af2b81d20d64d4a677d6bf5d4277496f8d6

Contents?: true

Size: 861 Bytes

Versions: 2

Compression:

Stored size: 861 Bytes

Contents

# frozen_string_literal: true

require 'roko/report_event'
require 'time'

module Roko
  module Source
    module Jira
      # event adapter from jira to report event
      module EventAdapter
        class << self
          # @param event [JIRA::Resource::Issue]
          # @return [Roko::ReportEvent]
          def to_report_event(event)
            source = 'jira'
            event_type = 'ticket'

            key = event.attrs['key']
            url = "#{ENV['JIRA_URL']}#{ENV['JIRA_CONTEXT_PATH']}/browse/#{key}"

            fields = event.attrs['fields']

            created_at = Time.parse(fields['updated'])

            summary = "[#{key}] #{fields['summary']}"
            detail = fields['description']
            Roko::ReportEvent.new(source, event_type, created_at, url, summary, detail)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roko-0.2.1 lib/roko/source/jira/event_adapter.rb
roko-0.2.0 lib/roko/source/jira/event_adapter.rb