Class: ResponseForSyncResponse

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



3397
3398
3399
3400
3401
3402
3403
3404
# File 'lib/schemas.rb', line 3397

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

.from_json!(json) ⇒ Object



3406
3407
3408
# File 'lib/schemas.rb', line 3406

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

Instance Method Details

#to_dynamicObject



3410
3411
3412
3413
3414
3415
3416
# File 'lib/schemas.rb', line 3410

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

#to_json(options = nil) ⇒ Object



3418
3419
3420
# File 'lib/schemas.rb', line 3418

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