Class: ResponseForSecretsResponse

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



2129
2130
2131
2132
2133
2134
2135
2136
# File 'lib/schemas.rb', line 2129

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

.from_json!(json) ⇒ Object



2138
2139
2140
# File 'lib/schemas.rb', line 2138

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

Instance Method Details

#to_dynamicObject



2142
2143
2144
2145
2146
2147
2148
# File 'lib/schemas.rb', line 2142

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

#to_json(options = nil) ⇒ Object



2150
2151
2152
# File 'lib/schemas.rb', line 2150

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