Class: MistApi::CsrfTokenCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/mist_api/http/auth/csrf_token.rb

Overview

Data class for CsrfTokenCredentials. Data class for CsrfTokenCredentials.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x_csrf_token:) ⇒ CsrfTokenCredentials

Returns a new instance of CsrfTokenCredentials.

Raises:

  • (ArgumentError)


30
31
32
33
34
# File 'lib/mist_api/http/auth/csrf_token.rb', line 30

def initialize(x_csrf_token:)
  raise ArgumentError, 'x_csrf_token cannot be nil' if x_csrf_token.nil?

  @x_csrf_token = x_csrf_token
end

Instance Attribute Details

#x_csrf_tokenObject (readonly)

Returns the value of attribute x_csrf_token.



28
29
30
# File 'lib/mist_api/http/auth/csrf_token.rb', line 28

def x_csrf_token
  @x_csrf_token
end

Class Method Details

.from_envObject



36
37
38
39
40
41
42
43
44
# File 'lib/mist_api/http/auth/csrf_token.rb', line 36

def self.from_env
  x_csrf_token = ENV['CSRF_TOKEN_X_CSRF_TOKEN']
  all_nil = [
    x_csrf_token
  ].all?(&:nil?)
  return nil if all_nil

  new(x_csrf_token: x_csrf_token)
end

Instance Method Details

#clone_with(x_csrf_token: nil) ⇒ Object



46
47
48
49
50
# File 'lib/mist_api/http/auth/csrf_token.rb', line 46

def clone_with(x_csrf_token: nil)
  x_csrf_token ||= self.x_csrf_token

  CsrfTokenCredentials.new(x_csrf_token: x_csrf_token)
end