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



1920
1921
1922
1923
1924
1925
1926
1927
# File 'lib/schemas.rb', line 1920

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



1929
1930
1931
# File 'lib/schemas.rb', line 1929

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

Instance Method Details

#to_dynamicObject



1933
1934
1935
1936
1937
1938
1939
# File 'lib/schemas.rb', line 1933

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

#to_json(options = nil) ⇒ Object



1941
1942
1943
# File 'lib/schemas.rb', line 1941

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