Class: Morpheus::UsersInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::UsersInterface
- Defined in:
- lib/morpheus/api/users_interface.rb
Instance Method Summary collapse
- #create(account_id, options) ⇒ Object
- #destroy(account_id, id) ⇒ Object
- #get(account_id, id) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ UsersInterface
constructor
A new instance of UsersInterface.
- #list(account_id, options = {}) ⇒ Object
- #update(account_id, id, options) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ UsersInterface
Returns a new instance of UsersInterface.
6 7 8 9 10 11 |
# File 'lib/morpheus/api/users_interface.rb', line 6 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(account_id, options) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/morpheus/api/users_interface.rb', line 31 def create(account_id, ) url = build_url(account_id) headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = response = Morpheus::RestClient.execute(method: :post, url: url, timeout: 10, headers: headers, payload: payload.to_json) JSON.parse(response.to_s) end |
#destroy(account_id, id) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/morpheus/api/users_interface.rb', line 49 def destroy(account_id, id) url = build_url(account_id, id) headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } response = Morpheus::RestClient.execute(method: :delete, url: url, timeout: 10, headers: headers) JSON.parse(response.to_s) end |
#get(account_id, id) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/morpheus/api/users_interface.rb', line 13 def get(account_id, id) raise "#{self.class}.get() passed a blank id!" if id.to_s == '' url = build_url(account_id, id) headers = { params: {}, authorization: "Bearer #{@access_token}" } response = Morpheus::RestClient.execute(method: :get, url: url, timeout: 10, headers: headers) JSON.parse(response.to_s) end |
#list(account_id, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/morpheus/api/users_interface.rb', line 22 def list(account_id, ={}) url = build_url(account_id) headers = { params: {}, authorization: "Bearer #{@access_token}" } headers[:params].merge!() response = Morpheus::RestClient.execute(method: :get, url: url, timeout: 10, headers: headers) JSON.parse(response.to_s) end |
#update(account_id, id, options) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/morpheus/api/users_interface.rb', line 40 def update(account_id, id, ) url = build_url(account_id, id) headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = response = Morpheus::RestClient.execute(method: :put, url: url, timeout: 10, headers: headers, payload: payload.to_json) JSON.parse(response.to_s) end |