Class: GetMeResponse

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



10335
10336
10337
10338
10339
10340
10341
# File 'lib/schemas.rb', line 10335

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    operations: d["operations"]&.map { |x| GetMeResponseOperationsItem.from_dynamic!(x) },
    user:       d["user"] ? GetMeResponseUser.from_dynamic!(d["user"]) : nil,
  )
end

.from_json!(json) ⇒ Object



10343
10344
10345
# File 'lib/schemas.rb', line 10343

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

Instance Method Details

#to_dynamicObject



10347
10348
10349
10350
10351
10352
# File 'lib/schemas.rb', line 10347

def to_dynamic
  {
    "operations" => operations&.map { |x| x.to_dynamic },
    "user"       => user&.to_dynamic,
  }
end

#to_json(options = nil) ⇒ Object



10354
10355
10356
# File 'lib/schemas.rb', line 10354

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