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



3448
3449
3450
3451
3452
3453
3454
3455
# File 'lib/schemas.rb', line 3448

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



3457
3458
3459
# File 'lib/schemas.rb', line 3457

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

Instance Method Details

#to_dynamicObject



3461
3462
3463
3464
3465
3466
3467
# File 'lib/schemas.rb', line 3461

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

#to_json(options = nil) ⇒ Object



3469
3470
3471
# File 'lib/schemas.rb', line 3469

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