Class: PostMocksMockIDServerResponsesBodyServerResponse

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



24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
# File 'lib/schemas.rb', line 24210

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    body:                                                          d["body"],
    headers:                                                       d["headers"]&.map { |x| PostMocksMockIDServerResponsesBodyServerResponseHeadersItem.from_dynamic!(x) },
    language:                                                      d["language"],
    post_mocks_mock_id_server_responses_body_server_response_name: d.fetch("name"),
    status_code:                                                   d.fetch("statusCode"),
  )
end

.from_json!(json) ⇒ Object



24221
24222
24223
# File 'lib/schemas.rb', line 24221

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

Instance Method Details

#to_dynamicObject



24225
24226
24227
24228
24229
24230
24231
24232
24233
# File 'lib/schemas.rb', line 24225

def to_dynamic
  {
    "body"       => body,
    "headers"    => headers&.map { |x| x.to_dynamic },
    "language"   => language,
    "name"       => post_mocks_mock_id_server_responses_body_server_response_name,
    "statusCode" => status_code,
  }
end

#to_json(options = nil) ⇒ Object



24235
24236
24237
# File 'lib/schemas.rb', line 24235

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