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



2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
# File 'lib/schemas.rb', line 2105

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



2116
2117
2118
# File 'lib/schemas.rb', line 2116

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

Instance Method Details

#to_dynamicObject



2120
2121
2122
2123
2124
2125
2126
2127
2128
# File 'lib/schemas.rb', line 2120

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

#to_json(options = nil) ⇒ Object



2130
2131
2132
# File 'lib/schemas.rb', line 2130

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