Class: ResponseForSecretResponse

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



2067
2068
2069
2070
2071
2072
2073
2074
# File 'lib/schemas.rb', line 2067

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

.from_json!(json) ⇒ Object



2076
2077
2078
# File 'lib/schemas.rb', line 2076

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

Instance Method Details

#to_dynamicObject



2080
2081
2082
2083
2084
2085
2086
# File 'lib/schemas.rb', line 2080

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

#to_json(options = nil) ⇒ Object



2088
2089
2090
# File 'lib/schemas.rb', line 2088

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