Class: ApiApplication

Inherits:
ApplicationRecord show all
Includes:
SharedBehaviour::Named
Defined in:
app/models/api_application.rb

Overview

An external application using the V1 API Provides an api_key which can be used to authenticate the application, as well as contact information should the API change

Instance Method Summary collapse

Methods included from SharedBehaviour::Named

included

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Method Details

#generate_new_api_keyObject



16
17
18
# File 'app/models/api_application.rb', line 16

def generate_new_api_key
  self.key = SecureRandom.base64(configatron.fetch('api_key_length') || 20)
end

#generate_new_api_key!Object



20
21
22
23
# File 'app/models/api_application.rb', line 20

def generate_new_api_key!
  generate_new_api_key
  save!
end