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



1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
# File 'lib/schemas.rb', line 1620

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



1633
1634
1635
# File 'lib/schemas.rb', line 1633

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

Instance Method Details

#to_dynamicObject



1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
# File 'lib/schemas.rb', line 1637

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



1649
1650
1651
# File 'lib/schemas.rb', line 1649

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