Class: PasswordLoginRequest

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schemas.rb

Overview

Login to Bitwarden with Username and Password

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



692
693
694
695
696
697
698
699
700
# File 'lib/schemas.rb', line 692

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    email:      d.fetch("email"),
    kdf:        Kdf.from_dynamic!(d.fetch("kdf")),
    password:   d.fetch("password"),
    two_factor: d["twoFactor"] ? TwoFactorRequest.from_dynamic!(d["twoFactor"]) : nil,
  )
end

.from_json!(json) ⇒ Object



702
703
704
# File 'lib/schemas.rb', line 702

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

Instance Method Details

#to_dynamicObject



706
707
708
709
710
711
712
713
# File 'lib/schemas.rb', line 706

def to_dynamic
  {
    "email"     => email,
    "kdf"       => kdf.to_dynamic,
    "password"  => password,
    "twoFactor" => two_factor&.to_dynamic,
  }
end

#to_json(options = nil) ⇒ Object



715
716
717
# File 'lib/schemas.rb', line 715

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