Class: ActiveProject::Adapters::JiraAdapter

Overview

Adapter for interacting with the Jira REST API. Implements the interface defined in ActiveProject::Adapters::Base.

Constant Summary

Constants included from ActiveProject::Adapters::Jira::Issues

ActiveProject::Adapters::Jira::Issues::DEFAULT_FIELDS

Constants included from ActiveProject::Adapters::Jira::Connection

ActiveProject::Adapters::Jira::Connection::SERAPH_HEADER

Constants included from Connections::HttpClient

Connections::HttpClient::DEFAULT_HEADERS, Connections::HttpClient::DEFAULT_RETRY_OPTS

Instance Attribute Summary collapse

Attributes included from Connections::HttpClient

#connection, #last_response

Instance Method Summary collapse

Methods included from ActiveProject::Adapters::Jira::Webhooks

#parse_webhook

Methods included from ActiveProject::Adapters::Jira::Transitions

#transition_issue

Methods included from ActiveProject::Adapters::Jira::Comments

#add_comment, #delete_comment, #update_comment

Methods included from ActiveProject::Adapters::Jira::Issues

#adf_text, #delete_issue, #find_issue, #list_issues

Methods included from ActiveProject::Adapters::Jira::Projects

#create_project, #delete_project, #find_project, #list_projects

Methods included from ActiveProject::Adapters::Jira::Connection

#initialize

Methods included from Connections::Rest

#init_rest, #request_rest

Methods included from Connections::Pagination

#each_edge, #each_page

Methods included from Connections::HttpClient

#build_connection, #request

Methods included from Connections::Base

#parse_link_header

Methods included from ActiveProject::Adapters::Jira::AttributeNormalizer

#normalize_issue_attrs

Methods inherited from Base

#add_comment, #create_list, #create_project, #delete_comment, #delete_issue, #delete_project, #denormalize_status, #find_issue, #find_project, #initialize, #list_issues, #list_projects, #normalize_status, #parse_webhook, #status_known?, #supports_webhooks?, #update_comment, #valid_statuses, #verify_webhook_signature, webhook_type, #webhook_type

Instance Attribute Details

#configObject (readonly)

Store the config object



15
16
17
# File 'lib/active_project/adapters/jira_adapter.rb', line 15

def config
  @config
end

Instance Method Details

#connected?Boolean

Checks if the adapter can successfully authenticate and connect to the service. Calls #get_current_user internally and catches authentication errors.

Returns:

  • (Boolean)

    true if connection is successful, false otherwise.



67
68
69
70
71
72
# File 'lib/active_project/adapters/jira_adapter.rb', line 67

def connected?
  get_current_user
  true
rescue ActiveProject::AuthenticationError
  false
end

#create_issue(project_id_or_key, attributes) ⇒ ActiveProject::Resources::Issue

Creates an issue in Jira.

Parameters:

  • project_id_or_key (String, Integer)

    The project ID or key (used by Jira to determine project).

  • attributes (Hash)

    Issue attributes including :project, :summary, :issue_type.

Returns:



42
43
44
# File 'lib/active_project/adapters/jira_adapter.rb', line 42

def create_issue(project_id_or_key, attributes)
  super(project_id_or_key, normalize_issue_attrs(attributes))
end

#get_current_userActiveProject::Resources::User

Retrieves details for the currently authenticated user.

Returns:

Raises:



59
60
61
62
# File 'lib/active_project/adapters/jira_adapter.rb', line 59

def get_current_user
  user_data = make_request(:get, "/rest/api/3/myself")
  map_user_data(user_data)
end

#issuesResourceFactory<Resources::Issue>

Returns a factory for Issue resources.



34
35
36
# File 'lib/active_project/adapters/jira_adapter.rb', line 34

def issues
  ResourceFactory.new(adapter: self, resource_class: Resources::Issue)
end

#projectsResourceFactory<Resources::Project>

Returns a factory for Project resources.



28
29
30
# File 'lib/active_project/adapters/jira_adapter.rb', line 28

def projects
  ResourceFactory.new(adapter: self, resource_class: Resources::Project)
end

#update_issue(id_or_key, attributes, context = {}) ⇒ ActiveProject::Resources::Issue

Updates an issue in Jira.

Parameters:

  • id_or_key (String, Integer)

    The issue ID or key.

  • attributes (Hash)

    Attributes to update.

  • context (Hash) (defaults to: {})

    Optional context (e.g., :fields for return selection).

Returns:



51
52
53
# File 'lib/active_project/adapters/jira_adapter.rb', line 51

def update_issue(id_or_key, attributes, context = {})
  super(id_or_key, normalize_issue_attrs(attributes), context)
end