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_TIMEOUT_OPTIONS, Gitlab::HTTP::HTTP_ERRORS, Gitlab::HTTP::HTTP_TIMEOUT_ERRORS, 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
  Gitlab::Metrics::System.monotonic_time.to_i
end

Instance Method Details

#store_dev_info(project:, commits: nil, branches: nil, merge_requests: nil, update_sequence_id: nil) ⇒ Object


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

def store_dev_info(project:, commits: nil, branches: nil, merge_requests: nil, update_sequence_id: nil)
  dev_info_json = {
    repositories: [
      Serializers::RepositoryEntity.represent(
        project,
        commits: commits,
        branches: branches,
        merge_requests: merge_requests,
        user_notes_count: user_notes_count(merge_requests),
        update_sequence_id: update_sequence_id
      )
    ]
  }.to_json

  uri = URI.join(@base_uri, '/rest/devinfo/0.10/bulk')

  headers = {
    'Authorization' => "JWT #{jwt_token('POST', uri)}",
    'Content-Type' => 'application/json'
  }

  self.class.post(uri, headers: headers, body: dev_info_json)
end