Class: Morpheus::LicenseInterface

Inherits:
APIClient
  • Object
show all
Defined in:
lib/morpheus/api/license_interface.rb

Instance Method Summary collapse

Constructor Details

#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ LicenseInterface

Returns a new instance of LicenseInterface.



4
5
6
7
8
9
# File 'lib/morpheus/api/license_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

#apply(key) ⇒ Object



17
18
19
20
21
22
# File 'lib/morpheus/api/license_interface.rb', line 17

def apply(key)
  url = "#{@base_url}/api/license"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  payload = {license: key}
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
end

#decode(key) ⇒ Object



24
25
26
27
28
29
# File 'lib/morpheus/api/license_interface.rb', line 24

def decode(key)
  url = "#{@base_url}/api/license/decode"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  payload = {license: key}
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
end

#getObject



11
12
13
14
15
# File 'lib/morpheus/api/license_interface.rb', line 11

def get()
  url = "#{@base_url}/api/license"
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end