Class: ProjectResponse

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



2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
# File 'lib/schemas.rb', line 2317

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    creation_date:         d.fetch("creationDate"),
    id:                    d.fetch("id"),
    project_response_name: d.fetch("name"),
    organization_id:       d.fetch("organizationId"),
    revision_date:         d.fetch("revisionDate"),
  )
end

.from_json!(json) ⇒ Object



2328
2329
2330
# File 'lib/schemas.rb', line 2328

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

Instance Method Details

#to_dynamicObject



2332
2333
2334
2335
2336
2337
2338
2339
2340
# File 'lib/schemas.rb', line 2332

def to_dynamic
  {
    "creationDate"   => creation_date,
    "id"             => id,
    "name"           => project_response_name,
    "organizationId" => organization_id,
    "revisionDate"   => revision_date,
  }
end

#to_json(options = nil) ⇒ Object



2342
2343
2344
# File 'lib/schemas.rb', line 2342

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