Class: Morpheus::OptionTypesInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::OptionTypesInterface
- Defined in:
- lib/morpheus/api/option_types_interface.rb
Instance Method Summary collapse
- #create(payload) ⇒ Object
- #destroy(id) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ OptionTypesInterface
constructor
A new instance of OptionTypesInterface.
- #list(params = {}) ⇒ Object
- #update(id, payload) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ OptionTypesInterface
Returns a new instance of OptionTypesInterface.
4 5 6 7 8 9 |
# File 'lib/morpheus/api/option_types_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(payload) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/morpheus/api/option_types_interface.rb', line 27 def create(payload) url = "#{@base_url}/api/library/option-types" headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :post, url: url, headers: headers, payload: payload.to_json} execute(opts) end |
#destroy(id) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/morpheus/api/option_types_interface.rb', line 41 def destroy(id) url = "#{@base_url}/api/library/option-types/#{id}" headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :delete, url: url, headers: headers} execute(opts) end |
#get(id) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/morpheus/api/option_types_interface.rb', line 11 def get(id) raise "#{self.class}.get() passed a blank id!" if id.to_s == '' url = "#{@base_url}/api/library/option-types/#{id}" headers = { params: {}, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#list(params = {}) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/morpheus/api/option_types_interface.rb', line 19 def list(params={}) url = "#{@base_url}/api/library/option-types" headers = { params: {}, authorization: "Bearer #{@access_token}" } headers[:params].merge!(params) opts = {method: :get, url: url, headers: headers} execute(opts) end |
#update(id, payload) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/morpheus/api/option_types_interface.rb', line 34 def update(id, payload) url = "#{@base_url}/api/library/option-types/#{id}" headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } opts = {method: :put, url: url, headers: headers, payload: payload.to_json} execute(opts) end |