Class: Morpheus::TasksInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::TasksInterface
- Defined in:
- lib/morpheus/api/tasks_interface.rb
Instance Method Summary collapse
- #create(options) ⇒ Object
- #destroy(id) ⇒ Object
- #get(options = nil) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ TasksInterface
constructor
A new instance of TasksInterface.
- #task_types(options = {}) ⇒ Object
- #update(id, options) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ TasksInterface
Returns a new instance of TasksInterface.
4 5 6 7 8 9 |
# File 'lib/morpheus/api/tasks_interface.rb', line 4 def initialize(access_token, refresh_token,expires_at = nil, base_url=nil) @access_token = access_token @refresh_token = refresh_token @base_url = base_url @expires_at = expires_at end |
Instance Method Details
#create(options) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/morpheus/api/tasks_interface.rb', line 47 def create() url = "#{@base_url}/api/tasks" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = execute(method: :post, url: url, headers: headers, payload: payload.to_json) end |
#destroy(id) ⇒ Object
54 55 56 57 58 |
# File 'lib/morpheus/api/tasks_interface.rb', line 54 def destroy(id) url = "#{@base_url}/api/tasks/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } execute(method: :delete, url: url, headers: headers) end |
#get(options = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/morpheus/api/tasks_interface.rb', line 25 def get(=nil) url = "#{@base_url}/api/tasks" headers = { params: {}, authorization: "Bearer #{@access_token}" } if .is_a?(Hash) headers[:params].merge!() elsif .is_a?(Numeric) url = "#{@base_url}/api/tasks/#{}" elsif .is_a?(String) headers[:params]['name'] = end execute(method: :get, url: url, headers: headers) end |
#task_types(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/morpheus/api/tasks_interface.rb', line 11 def task_types(={}) url = "#{@base_url}/api/task-types" headers = { params: {}, authorization: "Bearer #{@access_token}" } if .is_a?(Hash) headers[:params].merge!() elsif .is_a?(Numeric) url = "#{@base_url}/api/task-types/#{}" elsif .is_a?(String) headers[:params]['name'] = end execute(method: :get, url: url, headers: headers) end |
#update(id, options) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/morpheus/api/tasks_interface.rb', line 39 def update(id, ) url = "#{@base_url}/api/tasks/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = execute(method: :put, url: url, headers: headers, payload: payload.to_json) end |