Class: SingularityClient::API

Inherits:
Object
  • Object
show all
Defined in:
lib/singularity_client/api.rb

Overview

Handles the singularity api

Class Method Summary collapse

Class Method Details

.add(config, repo, project) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/singularity_client/api.rb', line 20

def self.add(config, repo, project)
  endpoint = 'config/pull_request'
  post_data = {
    organization: config.organization,
    repo: repo,
    project: project
  }

  request = SingularityClient::Request.new(config)
  request.post(endpoint, post_data)

  puts('success!')
end

.comment(config, repo, pr, comment) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/singularity_client/api.rb', line 34

def self.comment(config, repo, pr, comment)
  # if pr is not a number, pr.to_i will return 0
  # zero is not a valid pull-request identifier
  fail('ERROR invalid pull-request provided') if pr.to_i == 0

  endpoint = 'comment'
  post_data = {
    organization: config.organization,
    repo: repo,
    pull_request: pr,
    message: comment
  }

  request = SingularityClient::Request.new(config)
  request.post(endpoint, post_data)

  puts('success!')
end

.config(config) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/singularity_client/api.rb', line 11

def self.config(config)
  endpoint = 'config'

  request = SingularityClient::Request.new(config)
  response = request.get(endpoint)

  pp(JSON.parse(response.body))
end