Class: TwoFactorProviders

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



1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
# File 'lib/schemas.rb', line 1473

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    authenticator:    d["authenticator"] ? Authenticator.from_dynamic!(d["authenticator"]) : nil,
    duo:              d["duo"] ? Duo.from_dynamic!(d["duo"]) : nil,
    email:            d["email"] ? Email.from_dynamic!(d["email"]) : nil,
    organization_duo: d["organizationDuo"] ? Duo.from_dynamic!(d["organizationDuo"]) : nil,
    remember:         d["remember"] ? Remember.from_dynamic!(d["remember"]) : nil,
    web_authn:        d["webAuthn"] ? WebAuthn.from_dynamic!(d["webAuthn"]) : nil,
    yubi_key:         d["yubiKey"] ? YubiKey.from_dynamic!(d["yubiKey"]) : nil,
  )
end

.from_json!(json) ⇒ Object



1486
1487
1488
# File 'lib/schemas.rb', line 1486

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

Instance Method Details

#to_dynamicObject



1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
# File 'lib/schemas.rb', line 1490

def to_dynamic
  {
    "authenticator"   => authenticator&.to_dynamic,
    "duo"             => duo&.to_dynamic,
    "email"           => email&.to_dynamic,
    "organizationDuo" => organization_duo&.to_dynamic,
    "remember"        => remember&.to_dynamic,
    "webAuthn"        => web_authn&.to_dynamic,
    "yubiKey"         => yubi_key&.to_dynamic,
  }
end

#to_json(options = nil) ⇒ Object



1502
1503
1504
# File 'lib/schemas.rb', line 1502

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