Class: ResponseForPasswordLoginResponse

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



1815
1816
1817
1818
1819
1820
1821
1822
# File 'lib/schemas.rb', line 1815

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    data:          d["data"] ? PasswordLoginResponse.from_dynamic!(d["data"]) : nil,
    error_message: d["errorMessage"],
    success:       d.fetch("success"),
  )
end

.from_json!(json) ⇒ Object



1824
1825
1826
# File 'lib/schemas.rb', line 1824

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

Instance Method Details

#to_dynamicObject



1828
1829
1830
1831
1832
1833
1834
# File 'lib/schemas.rb', line 1828

def to_dynamic
  {
    "data"         => data&.to_dynamic,
    "errorMessage" => error_message,
    "success"      => success,
  }
end

#to_json(options = nil) ⇒ Object



1836
1837
1838
# File 'lib/schemas.rb', line 1836

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