Class: Attachment

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



2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
# File 'lib/schemas.rb', line 2397

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    file_name: d["fileName"],
    id:        d["id"],
    key:       d["key"],
    size:      d["size"],
    size_name: d["sizeName"],
    url:       d["url"],
  )
end

.from_json!(json) ⇒ Object



2409
2410
2411
# File 'lib/schemas.rb', line 2409

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

Instance Method Details

#to_dynamicObject



2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
# File 'lib/schemas.rb', line 2413

def to_dynamic
  {
    "fileName" => file_name,
    "id"       => id,
    "key"      => key,
    "size"     => size,
    "sizeName" => size_name,
    "url"      => url,
  }
end

#to_json(options = nil) ⇒ Object



2424
2425
2426
# File 'lib/schemas.rb', line 2424

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