Class: PasswordLoginResponse

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



1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
# File 'lib/schemas.rb', line 1774

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    authenticated:         d.fetch("authenticated"),
    captcha:               d["captcha"] ? CAPTCHAResponse.from_dynamic!(d["captcha"]) : nil,
    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



1785
1786
1787
# File 'lib/schemas.rb', line 1785

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

Instance Method Details

#to_dynamicObject



1789
1790
1791
1792
1793
1794
1795
1796
1797
# File 'lib/schemas.rb', line 1789

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

#to_json(options = nil) ⇒ Object



1799
1800
1801
# File 'lib/schemas.rb', line 1799

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