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



794
795
796
797
798
799
800
801
802
# File 'lib/schemas.rb', line 794

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



804
805
806
# File 'lib/schemas.rb', line 804

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

Instance Method Details

#to_dynamicObject



808
809
810
811
812
813
814
815
# File 'lib/schemas.rb', line 808

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

#to_json(options = nil) ⇒ Object



817
818
819
# File 'lib/schemas.rb', line 817

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