Class: ResponseForProjectResponse

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



2358
2359
2360
2361
2362
2363
2364
2365
# File 'lib/schemas.rb', line 2358

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

.from_json!(json) ⇒ Object



2367
2368
2369
# File 'lib/schemas.rb', line 2367

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

Instance Method Details

#to_dynamicObject



2371
2372
2373
2374
2375
2376
2377
# File 'lib/schemas.rb', line 2371

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

#to_json(options = nil) ⇒ Object



2379
2380
2381
# File 'lib/schemas.rb', line 2379

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