Class: GitlabRuby::Client
- Inherits:
-
Object
- Object
- GitlabRuby::Client
- 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
- #api_call(method_name, options, verb = :get) ⇒ Object
- #delete ⇒ Object
- #get ⇒ Object
-
#initialize(params = {}) ⇒ Client
constructor
A new instance of Client.
- #post ⇒ Object
- #put ⇒ Object
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
.debug ⇒ Object
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, , verb=:get) response = connection(method_name, , 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 |
#delete ⇒ Object
33 34 35 |
# File 'lib/gitlab_ruby/client.rb', line 33 def delete GitlabRuby::QueryChain.new(client: self, verb: :delete) end |
#get ⇒ Object
29 30 31 |
# File 'lib/gitlab_ruby/client.rb', line 29 def get GitlabRuby::QueryChain.new(client: self, verb: :get) end |
#post ⇒ Object
25 26 27 |
# File 'lib/gitlab_ruby/client.rb', line 25 def post GitlabRuby::QueryChain.new(client: self, verb: :post) end |
#put ⇒ Object
21 22 23 |
# File 'lib/gitlab_ruby/client.rb', line 21 def put GitlabRuby::QueryChain.new(client: self, verb: :put) end |