Class: VSTS::APIClient
- Inherits:
-
Object
- Object
- VSTS::APIClient
- Defined in:
- lib/vsts/api_client.rb
Overview
API client for Visual Studio Team Services (VSTS) Manages access tokens and API versions, builds proper requests as expected by the VSTS API
Class Method Summary collapse
-
.delete(resource, opts = {}) ⇒ Hash
Helper method for DELETE requests, calls #request.
-
.get(resource, opts = {}) ⇒ Hash
Helper method for GET requests, calls #request.
-
.patch(resource, payload, opts = {}) ⇒ Hash
Helper method for PATCH requests, calls #request.
-
.post(resource, payload, opts = {}) ⇒ Hash
Helper method for POST requests, calls #request.
-
.put(resource, payload, opts = {}) ⇒ Hash
Helper method for PUT requests, calls #request.
-
.request(method, resource, opts = {}) ⇒ Hash
Make an API request.
Class Method Details
.delete(resource, opts = {}) ⇒ Hash
Helper method for DELETE requests, calls #request
88 89 90 |
# File 'lib/vsts/api_client.rb', line 88 def self.delete(resource, opts = {}) request(:delete, resource, opts) end |
.get(resource, opts = {}) ⇒ Hash
Helper method for GET requests, calls #request
46 47 48 |
# File 'lib/vsts/api_client.rb', line 46 def self.get(resource, opts = {}) request(:get, resource, opts) end |
.patch(resource, payload, opts = {}) ⇒ Hash
Helper method for PATCH requests, calls #request
78 79 80 81 |
# File 'lib/vsts/api_client.rb', line 78 def self.patch(resource, payload, opts = {}) opts[:payload] = payload request(:patch, resource, opts) end |
.post(resource, payload, opts = {}) ⇒ Hash
Helper method for POST requests, calls #request
56 57 58 59 |
# File 'lib/vsts/api_client.rb', line 56 def self.post(resource, payload, opts = {}) opts[:payload] = payload request(:post, resource, opts) end |
.put(resource, payload, opts = {}) ⇒ Hash
Helper method for PUT requests, calls #request
67 68 69 70 |
# File 'lib/vsts/api_client.rb', line 67 def self.put(resource, payload, opts = {}) opts[:payload] = payload request(:put, resource, opts) end |
.request(method, resource, opts = {}) ⇒ Hash
Make an API request
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vsts/api_client.rb', line 24 def self.request(method, resource, opts = {}) url = build_url(resource, opts) VSTS.logger.debug("VSTS request: #{method} #{url}") if VSTS.configuration.debug req = { method: method, url: url, payload: opts[:payload], headers: { Authorization: authz_header_value, Accept: opts[:accept] || "application/json", "Content-Type" => opts[:content_type] || "application/json" } } resp = RestClient::Request.execute(req) APIResponse.new(req, resp) end |