Class: APIResultForAccessTokenSuccessResponse

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



925
926
927
928
929
930
931
932
# File 'lib/schemas.rb', line 925

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    data:    d["data"] ? AccessTokenSuccessResponse.from_dynamic!(d["data"]) : nil,
    message: d["message"],
    status:  d.fetch("status"),
  )
end

.from_json!(json) ⇒ Object



934
935
936
# File 'lib/schemas.rb', line 934

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

Instance Method Details

#to_dynamicObject



938
939
940
941
942
943
944
# File 'lib/schemas.rb', line 938

def to_dynamic
  {
    "data"    => data&.to_dynamic,
    "message" => message,
    "status"  => status,
  }
end

#to_json(options = nil) ⇒ Object



946
947
948
# File 'lib/schemas.rb', line 946

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