Class: Atlassian::JiraConnect::Client

Inherits:
Gitlab::HTTP show all
Defined in:
lib/atlassian/jira_connect/client.rb

Constant Summary

Constants inherited from Gitlab::HTTP

Gitlab::HTTP::BlockedUrlError, Gitlab::HTTP::DEFAULT_READ_TOTAL_TIMEOUT, Gitlab::HTTP::DEFAULT_TIMEOUT_OPTIONS, Gitlab::HTTP::HTTP_ERRORS, Gitlab::HTTP::HTTP_TIMEOUT_ERRORS, Gitlab::HTTP::HeaderReadTimeout, Gitlab::HTTP::ReadTotalTimeout, Gitlab::HTTP::RedirectionTooDeep

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Gitlab::HTTP

httparty_perform_request, perform_request, try_get

Constructor Details

#initialize(base_uri, shared_secret) ⇒ Client

Returns a new instance of Client.


10
11
12
13
# File 'lib/atlassian/jira_connect/client.rb', line 10

def initialize(base_uri, shared_secret)
  @base_uri = base_uri
  @shared_secret = shared_secret
end

Class Method Details

.generate_update_sequence_idObject


6
7
8
# File 'lib/atlassian/jira_connect/client.rb', line 6

def self.generate_update_sequence_id
  (Time.now.utc.to_f * 1000).round
end

Instance Method Details

#send_info(project:, update_sequence_id: nil, **args) ⇒ Object

Raises:

  • (ArgumentError)

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/atlassian/jira_connect/client.rb', line 15

def send_info(project:, update_sequence_id: nil, **args)
  common = { project: project, update_sequence_id: update_sequence_id }
  dev_info = args.slice(:commits, :branches, :merge_requests)
  build_info = args.slice(:pipelines)
  deploy_info = args.slice(:deployments)
  ff_info = args.slice(:feature_flags)

  responses = []

  responses << store_dev_info(**common, **dev_info) if dev_info.present?
  responses << store_build_info(**common, **build_info) if build_info.present?
  responses << store_deploy_info(**common, **deploy_info) if deploy_info.present?
  responses << store_ff_info(**common, **ff_info) if ff_info.present?
  raise ArgumentError, 'Invalid arguments' if responses.empty?

  responses.compact
end

#user_info(account_id) ⇒ Object


33
34
35
36
37
# File 'lib/atlassian/jira_connect/client.rb', line 33

def ()
  r = get('/rest/api/3/user', { accountId: , expand: 'groups' })

  JiraUser.new(r.parsed_response) if r.code == 200
end