Class: Adminterface::Licensing::Base

Inherits:
Object
  • Object
show all
Extended by:
Callable
Defined in:
lib/adminterface/licensing/base.rb

Direct Known Subclasses

Commercial, Personal

Constant Summary collapse

ENDPOINT =
"https://app.adminterface.io/api/v1/licenses/verify".freeze
CACHE_KEY =
"adminterface.licensing.response".freeze
TIMEOUT =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(license_key = Adminterface.license_key) ⇒ Base

Returns a new instance of Base.



13
14
15
# File 'lib/adminterface/licensing/base.rb', line 13

def initialize(license_key = Adminterface.license_key)
  @license_key = license_key
end

Instance Attribute Details

#license_keyObject (readonly)

Returns the value of attribute license_key.



10
11
12
# File 'lib/adminterface/licensing/base.rb', line 10

def license_key
  @license_key
end

Instance Method Details

#callObject



17
18
19
20
21
22
# File 'lib/adminterface/licensing/base.rb', line 17

def call
  response = send_and_cache_request.with_indifferent_access
  Adminterface::Licensing::Notice
    .call(response, license_key, **{external: request?, endpoint: ENDPOINT})
  response
end

#payloadObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/adminterface/licensing/base.rb', line 24

def payload
  {
    license_key: encrypted_license_key,
    license: license,
    adminterface_version: Adminterface::VERSION,
    rails_version: Rails::VERSION::STRING,
    ruby_version: RUBY_VERSION,
    environment: Rails.env,
    app_name: app_name,
    verified: false
  }
end