Class: AccessTokenLoginResponse

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



1852
1853
1854
1855
1856
1857
1858
1859
1860
# File 'lib/schemas.rb', line 1852

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



1862
1863
1864
# File 'lib/schemas.rb', line 1862

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

Instance Method Details

#to_dynamicObject



1866
1867
1868
1869
1870
1871
1872
1873
# File 'lib/schemas.rb', line 1866

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

#to_json(options = nil) ⇒ Object



1875
1876
1877
# File 'lib/schemas.rb', line 1875

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