Class: APIKeyLoginResponse

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schemas.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



1665
1666
1667
1668
1669
1670
1671
1672
1673
# File 'lib/schemas.rb', line 1665

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    authenticated:         d.fetch("authenticated"),
    force_password_reset:  d.fetch("forcePasswordReset"),
    reset_master_password: d.fetch("resetMasterPassword"),
    two_factor:            d["twoFactor"] ? TwoFactorProviders.from_dynamic!(d["twoFactor"]) : nil,
  )
end

.from_json!(json) ⇒ Object



1675
1676
1677
# File 'lib/schemas.rb', line 1675

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



1679
1680
1681
1682
1683
1684
1685
1686
# File 'lib/schemas.rb', line 1679

def to_dynamic
  {
    "authenticated"       => authenticated,
    "forcePasswordReset"  => force_password_reset,
    "resetMasterPassword" => reset_master_password,
    "twoFactor"           => two_factor&.to_dynamic,
  }
end

#to_json(options = nil) ⇒ Object



1688
1689
1690
# File 'lib/schemas.rb', line 1688

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end