Class: ResponseForProjectsResponse

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



2420
2421
2422
2423
2424
2425
2426
2427
# File 'lib/schemas.rb', line 2420

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

.from_json!(json) ⇒ Object



2429
2430
2431
# File 'lib/schemas.rb', line 2429

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

Instance Method Details

#to_dynamicObject



2433
2434
2435
2436
2437
2438
2439
# File 'lib/schemas.rb', line 2433

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

#to_json(options = nil) ⇒ Object



2441
2442
2443
# File 'lib/schemas.rb', line 2441

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