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



1518
1519
1520
1521
1522
1523
1524
1525
1526
# File 'lib/schemas.rb', line 1518

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



1528
1529
1530
# File 'lib/schemas.rb', line 1528

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

Instance Method Details

#to_dynamicObject



1532
1533
1534
1535
1536
1537
1538
1539
# File 'lib/schemas.rb', line 1532

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

#to_json(options = nil) ⇒ Object



1541
1542
1543
# File 'lib/schemas.rb', line 1541

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