Class: Login

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



3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
# File 'lib/schemas.rb', line 3009

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    autofill_on_page_load:  d["autofillOnPageLoad"],
    fido2_credentials:      d["fido2Credentials"]&.map { |x| Fido2Credential.from_dynamic!(x) },
    password:               d["password"],
    password_revision_date: d["passwordRevisionDate"],
    totp:                   d["totp"],
    uris:                   d["uris"]&.map { |x| LoginURI.from_dynamic!(x) },
    username:               d["username"],
  )
end

.from_json!(json) ⇒ Object



3022
3023
3024
# File 'lib/schemas.rb', line 3022

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

Instance Method Details

#to_dynamicObject



3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
# File 'lib/schemas.rb', line 3026

def to_dynamic
  {
    "autofillOnPageLoad"   => autofill_on_page_load,
    "fido2Credentials"     => fido2_credentials&.map { |x| x.to_dynamic },
    "password"             => password,
    "passwordRevisionDate" => password_revision_date,
    "totp"                 => totp,
    "uris"                 => uris&.map { |x| x.to_dynamic },
    "username"             => username,
  }
end

#to_json(options = nil) ⇒ Object



3038
3039
3040
# File 'lib/schemas.rb', line 3038

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