Class: PostMocksResponseMock

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



24684
24685
24686
24687
24688
24689
24690
24691
24692
24693
24694
24695
24696
24697
# File 'lib/schemas.rb', line 24684

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    collection:  d["collection"],
    config:      d["config"] ? PostMocksResponseMockConfig.from_dynamic!(d["config"]) : nil,
    created_at:  d["createdAt"],
    environment: d["environment"],
    id:          d["id"],
    mock_url:    d["mockUrl"],
    owner:       d["owner"],
    uid:         d["uid"],
    updated_at:  d["updatedAt"],
  )
end

.from_json!(json) ⇒ Object



24699
24700
24701
# File 'lib/schemas.rb', line 24699

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

Instance Method Details

#to_dynamicObject



24703
24704
24705
24706
24707
24708
24709
24710
24711
24712
24713
24714
24715
# File 'lib/schemas.rb', line 24703

def to_dynamic
  {
    "collection"  => collection,
    "config"      => config&.to_dynamic,
    "createdAt"   => created_at,
    "environment" => environment,
    "id"          => id,
    "mockUrl"     => mock_url,
    "owner"       => owner,
    "uid"         => uid,
    "updatedAt"   => updated_at,
  }
end

#to_json(options = nil) ⇒ Object



24717
24718
24719
# File 'lib/schemas.rb', line 24717

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