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



3497
3498
3499
3500
3501
3502
3503
3504
# File 'lib/schemas.rb', line 3497

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



3506
3507
3508
# File 'lib/schemas.rb', line 3506

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

Instance Method Details

#to_dynamicObject



3510
3511
3512
3513
3514
3515
3516
# File 'lib/schemas.rb', line 3510

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

#to_json(options = nil) ⇒ Object



3518
3519
3520
# File 'lib/schemas.rb', line 3518

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