Class: ResponseForUserAPIKeyResponse

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



3548
3549
3550
3551
3552
3553
3554
3555
# File 'lib/schemas.rb', line 3548

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

.from_json!(json) ⇒ Object



3557
3558
3559
# File 'lib/schemas.rb', line 3557

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

Instance Method Details

#to_dynamicObject



3561
3562
3563
3564
3565
3566
3567
# File 'lib/schemas.rb', line 3561

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

#to_json(options = nil) ⇒ Object



3569
3570
3571
# File 'lib/schemas.rb', line 3569

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