Class: Verizon::VzM2MTokenCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/verizon/http/auth/vz_m2m_token.rb

Overview

Data class for VzM2MTokenCredentials. Data class for VzM2MTokenCredentials.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vz_m2m_token:) ⇒ VzM2MTokenCredentials

Returns a new instance of VzM2MTokenCredentials.

Raises:

  • (ArgumentError)


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

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

  @vz_m2m_token = vz_m2m_token
end

Instance Attribute Details

#vz_m2m_tokenObject (readonly)

Returns the value of attribute vz_m2m_token.



28
29
30
# File 'lib/verizon/http/auth/vz_m2m_token.rb', line 28

def vz_m2m_token
  @vz_m2m_token
end

Class Method Details

.from_envObject



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

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

  new(vz_m2m_token: vz_m2m_token)
end

Instance Method Details

#clone_with(vz_m2m_token: nil) ⇒ Object



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

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

  VzM2MTokenCredentials.new(vz_m2m_token: vz_m2m_token)
end