Sha256: c3f3eed10428ff73df419eec7165b0e077a7e9b1656738fe346d09f262885e4f

Contents?: true

Size: 1.59 KB

Versions: 2

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

require 'jira-ruby'
require_relative './fetch_current_tasks'
require_relative './fetch_current_task'
require_relative './move_task_to_list'
require_relative './get_task_name_by_id'

module Dude
  module ProjectManagement
    module Jira
      class Client
        attr_reader :client, :project

        def options
          {
            username: Dude::SETTINGS.dig(:jira, :email),
            password: Dude::SETTINGS.dig(:jira, :token),
            site: Dude::SETTINGS.dig(:jira, :project, :url),
            context_path: '',
            auth_type: :basic
          }
        end

        def initialize
          @client = JIRA::Client.new(options)
          @project = client.Project.find(Dude::SETTINGS.dig(:jira, :project, :key))
        rescue StandardError
          nil
        end

        def respond_to_missing?(method_name, include_private = false)
          client.respond_to_missing?(method_name, include_private)
        end

        def method_missing(method, *args, &block)
          client.send(method, *args, &block)
        end

        def fetch_current_tasks
          FetchCurrentTasks.new(client).call
        end

        def fetch_current_task(id)
          FetchCurrentTask.new(client, id: id).call
        end

        def move_task_to_list(id, list)
          MoveTaskToList.new(client, id: id, list_name: list).call
        end

        def get_task_name_by_id(id)
          GetTaskNameById.new(client, id: id).call
        end

        def health_check
          @project && true
        rescue StandardError
          false
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dude-cli-2.1.0 lib/dude/project_management/jira/client.rb
dude-cli-2.1.0.alpha5 lib/dude/project_management/jira/client.rb