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



1557
1558
1559
1560
1561
1562
1563
1564
# File 'lib/schemas.rb', line 1557

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



1566
1567
1568
# File 'lib/schemas.rb', line 1566

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

Instance Method Details

#to_dynamicObject



1570
1571
1572
1573
1574
1575
1576
# File 'lib/schemas.rb', line 1570

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

#to_json(options = nil) ⇒ Object



1578
1579
1580
# File 'lib/schemas.rb', line 1578

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