Class: GitlabRuby::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_ruby/client.rb

Constant Summary collapse

BASE_URL =
"https://gitlab.com/api/"
LATEST_VERSION =
'v4'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
# File 'lib/gitlab_ruby/client.rb', line 6

def initialize(params={})
  @token = params[:token]
  @urlstring = ""
  @endpoint = params[:endpoint] || BASE_URL
  @version = params[:version] || LATEST_VERSION
end

Class Method Details

.debugObject



13
14
15
# File 'lib/gitlab_ruby/client.rb', line 13

def self.debug
  @debug ||= false
end

.debug=(v) ⇒ Object



17
18
19
# File 'lib/gitlab_ruby/client.rb', line 17

def self.debug=(v)
  @debug = !!v
end

Instance Method Details

#api_call(method_name, options, verb = :get) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/gitlab_ruby/client.rb', line 37

def api_call(method_name, options, verb=:get)
  response = connection(method_name, options, verb)
  puts response.inspect if self.class.debug
  result = parse_response(response)
  if result.is_a? Array
    result.map { |item| APIObject.new(item) }
  elsif result.is_a? Hash
    APIObject.new(result)
  end
end

#deleteObject



33
34
35
# File 'lib/gitlab_ruby/client.rb', line 33

def delete
  GitlabRuby::QueryChain.new(client: self, verb: :delete)
end

#getObject



29
30
31
# File 'lib/gitlab_ruby/client.rb', line 29

def get
  GitlabRuby::QueryChain.new(client: self, verb: :get)
end

#postObject



25
26
27
# File 'lib/gitlab_ruby/client.rb', line 25

def post
  GitlabRuby::QueryChain.new(client: self, verb: :post)
end

#putObject



21
22
23
# File 'lib/gitlab_ruby/client.rb', line 21

def put
  GitlabRuby::QueryChain.new(client: self, verb: :put)
end