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

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Instance Method Details

#generate_new_api_keyObject


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

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

#generate_new_api_key!Object


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

def generate_new_api_key!
  generate_new_api_key
  save!
end