Class: Uploadcare::Param::AuthenticationHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/uploadcare/param/authentication_header.rb

Overview

This object returns headers needed for authentication This authentication method is more secure, but more tedious

Class Method Summary collapse

Class Method Details

.call(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/uploadcare/param/authentication_header.rb', line 13

def self.call(options = {})
  validate_auth_config
  case Uploadcare.config.auth_type
  when 'Uploadcare'
    SecureAuthHeader.call(options)
  when 'Uploadcare.Simple'
    SimpleAuthHeader.call
  else
    raise ArgumentError, "Unknown auth_scheme: '#{Uploadcare.config.auth_type}'"
  end
end

.is_blank?(value) ⇒ Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


31
32
33
# File 'lib/uploadcare/param/authentication_header.rb', line 31

def self.is_blank?(value)
  value.nil? || value.empty?
end

.validate_auth_configObject



25
26
27
28
# File 'lib/uploadcare/param/authentication_header.rb', line 25

def self.validate_auth_config
  raise Uploadcare::Exception::AuthError, 'Public Key is blank.' if is_blank?(Uploadcare.config.public_key)
  raise Uploadcare::Exception::AuthError, 'Secret Key is blank.' if is_blank?(Uploadcare.config.secret_key)
end