Class: BacklogKit::Client

Inherits:
Object
  • Object
show all
Includes:
Authorization, Git, Group, Issue, Notification, Priority, Project, Resolution, Space, Star, Status, Team, User, Watching, Wiki
Defined in:
lib/backlog_kit/client.rb,
lib/backlog_kit/client/git.rb,
lib/backlog_kit/client/star.rb,
lib/backlog_kit/client/team.rb,
lib/backlog_kit/client/user.rb,
lib/backlog_kit/client/wiki.rb,
lib/backlog_kit/client/group.rb,
lib/backlog_kit/client/issue.rb,
lib/backlog_kit/client/space.rb,
lib/backlog_kit/client/status.rb,
lib/backlog_kit/client/project.rb,
lib/backlog_kit/client/priority.rb,
lib/backlog_kit/client/watching.rb,
lib/backlog_kit/client/resolution.rb,
lib/backlog_kit/client/notification.rb,
lib/backlog_kit/client/authorization.rb

Overview

Client for the Backlog API

Defined Under Namespace

Modules: Authorization, Git, Group, Issue, Notification, Priority, Project, Resolution, Space, Star, Status, Team, User, Watching, Wiki

Constant Summary collapse

USER_AGENT =
"BacklogKit Ruby Gem #{BacklogKit::VERSION}".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Wiki

#create_wiki, #delete_wiki, #get_wiki, #get_wiki_count, #get_wiki_histories, #get_wiki_shared_files, #get_wiki_stars, #get_wiki_tags, #get_wikis, #link_wiki_shared_files, #unlink_wiki_shared_file, #update_wiki

Methods included from Watching

#add_watching, #get_watching, #get_watching_count, #get_watchings, #mark_as_read_watching, #mark_as_read_watchings, #remove_watching, #update_watching

Methods included from User

#create_user, #delete_user, #download_user_icon, #get_myself, #get_recently_viewed_issues, #get_recently_viewed_projects, #get_recently_viewed_wikis, #get_user, #get_user_activities, #get_user_star_count, #get_user_stars, #get_users, #update_user

Methods included from Team

#create_team, #delete_team, #download_team_icon, #get_team, #get_teams, #update_team

Methods included from Status

#get_statuses

Methods included from Star

#add_issue_comment_star, #add_issue_star, #add_pull_request_comment_star, #add_pull_request_star, #add_wiki_star

Methods included from Space

#download_space_icon, #get_space, #get_space_activities, #get_space_disk_usage, #get_space_notification, #update_space_notification, #upload_attachment

Methods included from Resolution

#get_resolutions

Methods included from Project

#add_category, #add_issue_type, #add_project_admin_auth, #add_project_team, #add_project_user, #add_pull_request_comment, #add_version, #add_webhook, #create_project, #create_pull_request, #delete_project, #download_project_icon, #download_pull_request_attachment, #download_shared_file, #get_categories, #get_issue_types, #get_project, #get_project_activities, #get_project_administrators, #get_project_disk_usage, #get_project_teams, #get_project_users, #get_projects, #get_pull_request, #get_pull_request_attachments, #get_pull_request_comment_count, #get_pull_request_comments, #get_pull_request_count, #get_pull_requests, #get_shared_files, #get_versions, #get_webhook, #get_webhooks, #remove_category, #remove_issue_type, #remove_project_admin_auth, #remove_project_team, #remove_project_user, #remove_pull_request_attachment, #remove_version, #remove_webhook, #update_category, #update_issue_type, #update_project, #update_pull_request, #update_pull_request_comment, #update_version, #update_webhook

Methods included from Priority

#get_priorities

Methods included from Notification

#get_notification_count, #get_notifications, #mark_as_read_notification, #reset_unread_notification_count

Methods included from Issue

#add_comment, #add_comment_notification, #create_issue, #delete_comment, #delete_issue, #download_issue_attachment, #get_comment, #get_comment_count, #get_comment_notifications, #get_comments, #get_issue, #get_issue_attachments, #get_issue_count, #get_issue_shared_files, #get_issues, #link_issue_shared_files, #remove_issue_attachment, #unlink_issue_shared_file, #update_comment, #update_issue

Methods included from Group

#create_group, #delete_group, #get_group, #get_groups, #update_group

Methods included from Git

#get_git_repositories

Methods included from Authorization

#create_token, #update_token

Constructor Details

#initialize(options = {}) ⇒ Client

Initialize a new Client object with given options

Parameters:

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

    Initialize options

Options Hash (options):

  • :space_id (String)

    Backlog space id

  • :second_level_domain (String)

    Backlog second level domain

  • :top_level_domain (String)

    Backlog top level domain

  • :api_key (String)

    Backlog api key

  • :client_id (String)

    Backlog OAuth client id

  • :client_secret (String)

    Backlog OAuth client secret

  • :refresh_token (String)

    Backlog OAuth refresh token



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/backlog_kit/client.rb', line 69

def initialize(options = {})
  @space_id            = ENV['BACKLOG_SPACE_ID']
  @second_level_domain = ENV['BACKLOG_SECOND_LEVEL_DOMAIN'] || 'backlog'
  @top_level_domain    = ENV['BACKLOG_TOP_LEVEL_DOMAIN'] || 'com'
  @api_key             = ENV['BACKLOG_API_KEY']
  @client_id           = ENV['BACKLOG_OAUTH_CLIENT_ID']
  @client_secret       = ENV['BACKLOG_OAUTH_CLIENT_SECRET']
  @refresh_token       = ENV['BACKLOG_OAUTH_REFRESH_TOKEN']

  options.each do |key, value|
    instance_variable_set(:"@#{key}", value)
  end
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



46
47
48
# File 'lib/backlog_kit/client.rb', line 46

def access_token
  @access_token
end

#api_keyObject

Returns the value of attribute api_key.



46
47
48
# File 'lib/backlog_kit/client.rb', line 46

def api_key
  @api_key
end

#client_idObject

Returns the value of attribute client_id.



46
47
48
# File 'lib/backlog_kit/client.rb', line 46

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



46
47
48
# File 'lib/backlog_kit/client.rb', line 46

def client_secret
  @client_secret
end

#redirect_uriObject

Returns the value of attribute redirect_uri.



46
47
48
# File 'lib/backlog_kit/client.rb', line 46

def redirect_uri
  @redirect_uri
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



46
47
48
# File 'lib/backlog_kit/client.rb', line 46

def refresh_token
  @refresh_token
end

#second_level_domainObject

Returns the value of attribute second_level_domain.



46
47
48
# File 'lib/backlog_kit/client.rb', line 46

def second_level_domain
  @second_level_domain
end

#space_idObject

Returns the value of attribute space_id.



46
47
48
# File 'lib/backlog_kit/client.rb', line 46

def space_id
  @space_id
end

#stateObject

Returns the value of attribute state.



46
47
48
# File 'lib/backlog_kit/client.rb', line 46

def state
  @state
end

#top_level_domainObject

Returns the value of attribute top_level_domain.



46
47
48
# File 'lib/backlog_kit/client.rb', line 46

def top_level_domain
  @top_level_domain
end

Instance Method Details

#authorization_urlString

Generate an OAuth authorization URL

Returns:

  • (String)

    OAuth authorization URL



86
87
88
89
90
91
# File 'lib/backlog_kit/client.rb', line 86

def authorization_url
  url = "#{host}/OAuth2AccessRequest.action?response_type=code&client_id=#{@client_id}"
  url += "&redirect_uri=#{URI.escape(@redirect_uri)}" if @redirect_uri
  url += "&state=#{@state}" if @state
  url
end

#delete(path, params = {}) ⇒ BacklogKit::Response

Make a HTTP DELETE request

Parameters:

  • path (String)

    Path for request

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

    Request parameters

Returns:



134
135
136
# File 'lib/backlog_kit/client.rb', line 134

def delete(path, params = {})
  request(:delete, path, params)
end

#get(path, params = {}) ⇒ BacklogKit::Response

Make a HTTP GET request

Parameters:

  • path (String)

    Path for request

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

    Request parameters

Returns:



98
99
100
# File 'lib/backlog_kit/client.rb', line 98

def get(path, params = {})
  request(:get, path, params)
end

#patch(path, params = {}) ⇒ BacklogKit::Response

Make a HTTP PATCH request

Parameters:

  • path (String)

    Path for request

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

    Request parameters

Returns:



125
126
127
# File 'lib/backlog_kit/client.rb', line 125

def patch(path, params = {})
  request(:patch, path, params)
end

#post(path, params = {}) ⇒ BacklogKit::Response

Make a HTTP POST request

Parameters:

  • path (String)

    Path for request

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

    Request parameters

Returns:



107
108
109
# File 'lib/backlog_kit/client.rb', line 107

def post(path, params = {})
  request(:post, path, params)
end

#put(path, params = {}) ⇒ BacklogKit::Response

Make a HTTP PUT request

Parameters:

  • path (String)

    Path for request

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

    Request parameters

Returns:



116
117
118
# File 'lib/backlog_kit/client.rb', line 116

def put(path, params = {})
  request(:put, path, params)
end