Class: Youtrack::Client
- Inherits:
-
Object
- Object
- Youtrack::Client
- Defined in:
- lib/youtrack/client.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #delete(path, options = {}) ⇒ Object
- #execute(method, path, options = {}) ⇒ Object
- #get(path, options = {}) ⇒ Object
-
#initialize(base_url:, token:) ⇒ Client
constructor
A new instance of Client.
- #issues ⇒ Object
- #post(path, payload, options = {}) ⇒ Object
- #projects ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(base_url:, token:) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 |
# File 'lib/youtrack/client.rb', line 9 def initialize(base_url:, token:) @base_url = normalize_base_url(base_url) @token = token RestClient.log = $stdout if ENV["DEBUG"] end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
7 8 9 |
# File 'lib/youtrack/client.rb', line 7 def base_url @base_url end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
7 8 9 |
# File 'lib/youtrack/client.rb', line 7 def token @token end |
Instance Method Details
#delete(path, options = {}) ⇒ Object
35 36 37 |
# File 'lib/youtrack/client.rb', line 35 def delete(path, = {}) execute(:delete, path, ) end |
#execute(method, path, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/youtrack/client.rb', line 39 def execute(method, path, = {}) RestClient::Request.execute( method: method, url: request_url(path), headers: default_headers .merge(.delete(:headers) || {}) .merge(params: .delete(:params) || {}), ** ) rescue RestClient::Exception => e if e.http_body.present? e. = e.http_body end raise e end |
#get(path, options = {}) ⇒ Object
27 28 29 |
# File 'lib/youtrack/client.rb', line 27 def get(path, = {}) execute(:get, path, ) end |
#issues ⇒ Object
19 20 21 |
# File 'lib/youtrack/client.rb', line 19 def issues @issues ||= Resources::Issues.new(client: self) end |
#post(path, payload, options = {}) ⇒ Object
31 32 33 |
# File 'lib/youtrack/client.rb', line 31 def post(path, payload, = {}) execute(:post, path, .merge(payload: payload)) end |