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



2208
2209
2210
2211
2212
2213
2214
2215
# File 'lib/schemas.rb', line 2208

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



2217
2218
2219
# File 'lib/schemas.rb', line 2217

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

Instance Method Details

#to_dynamicObject



2221
2222
2223
2224
2225
2226
2227
# File 'lib/schemas.rb', line 2221

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

#to_json(options = nil) ⇒ Object



2229
2230
2231
# File 'lib/schemas.rb', line 2229

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