Class: ResponseForAPIKeyLoginResponse

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



1704
1705
1706
1707
1708
1709
1710
1711
# File 'lib/schemas.rb', line 1704

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

.from_json!(json) ⇒ Object



1713
1714
1715
# File 'lib/schemas.rb', line 1713

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

Instance Method Details

#to_dynamicObject



1717
1718
1719
1720
1721
1722
1723
# File 'lib/schemas.rb', line 1717

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

#to_json(options = nil) ⇒ Object



1725
1726
1727
# File 'lib/schemas.rb', line 1725

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