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