Class: Hook0::Generated::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/hook0/generated/models.rb

Overview

The Response the API declares.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_id:, body: nil, elapsed_time_ms: nil, headers: nil, http_code: nil, response_error_name: nil) ⇒ Response

Returns a new instance of Response.

Parameters:

  • response_id (String)

    carries response_id.

  • body (String, nil) (defaults to: nil)

    carries body.

  • elapsed_time_ms (Integer, nil) (defaults to: nil)

    carries elapsed_time_ms.

  • headers (Hash{String => String}, nil) (defaults to: nil)

    carries headers.

  • http_code (Integer, nil) (defaults to: nil)

    carries http_code.

  • response_error_name (String, nil) (defaults to: nil)

    carries response_error_name.



2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
# File 'lib/hook0/generated/models.rb', line 2560

def initialize(
  response_id:,
  body: nil,
  elapsed_time_ms: nil,
  headers: nil,
  http_code: nil,
  response_error_name: nil
)
  @response_id = response_id
  @body = body
  @elapsed_time_ms = elapsed_time_ms
  @headers = headers
  @http_code = http_code
  @response_error_name = response_error_name
  freeze
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



2547
2548
2549
# File 'lib/hook0/generated/models.rb', line 2547

def body
  @body
end

#elapsed_time_msObject (readonly)

Returns the value of attribute elapsed_time_ms.



2547
2548
2549
# File 'lib/hook0/generated/models.rb', line 2547

def elapsed_time_ms
  @elapsed_time_ms
end

#headersObject (readonly)

Returns the value of attribute headers.



2547
2548
2549
# File 'lib/hook0/generated/models.rb', line 2547

def headers
  @headers
end

#http_codeObject (readonly)

Returns the value of attribute http_code.



2547
2548
2549
# File 'lib/hook0/generated/models.rb', line 2547

def http_code
  @http_code
end

#response_error_nameObject (readonly)

Returns the value of attribute response_error_name.



2547
2548
2549
# File 'lib/hook0/generated/models.rb', line 2547

def response_error_name
  @response_error_name
end

#response_idObject (readonly)

Returns the value of attribute response_id.



2547
2548
2549
# File 'lib/hook0/generated/models.rb', line 2547

def response_id
  @response_id
end

Class Method Details

.from_json(value) ⇒ Response

Read one out of what the API answered.

Parameters:

  • value (Object)

    the JSON document the API answered

Returns:



2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
# File 'lib/hook0/generated/models.rb', line 2581

def self.from_json(value)
  fields = Runtime.as_fields(value, "Response")
  new(
    response_id: Runtime.read(fields, "response_id", Runtime::UUID),
    body: Runtime.maybe(fields, "body", Runtime::TEXT),
    elapsed_time_ms: Runtime.maybe(fields, "elapsed_time_ms", Runtime::INTEGER),
    headers: Runtime.maybe(fields, "headers", Runtime.map(Runtime::TEXT)),
    http_code: Runtime.maybe(fields, "http_code", Runtime::INTEGER),
    response_error_name: Runtime.maybe(fields, "response_error_name", Runtime::TEXT)
  )
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Whether that value carries the same members as this one.

Parameters:

  • other (Object)

Returns:

  • (Boolean)


2611
2612
2613
# File 'lib/hook0/generated/models.rb', line 2611

def ==(other)
  other.is_a?(Response) && to_h == other.to_h
end

#hashInteger

A value two equal instances share, so that either may key a hash.

Returns:

  • (Integer)


2619
2620
2621
# File 'lib/hook0/generated/models.rb', line 2619

def hash
  to_h.hash
end

#to_hHash{String => Object}

Write one back the way the API reads it.

Returns:

  • (Hash{String => Object})


2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
# File 'lib/hook0/generated/models.rb', line 2596

def to_h
  out = {}
  out["response_id"] = @response_id
  out["body"] = @body unless @body.nil?
  out["elapsed_time_ms"] = @elapsed_time_ms unless @elapsed_time_ms.nil?
  out["headers"] = @headers unless @headers.nil?
  out["http_code"] = @http_code unless @http_code.nil?
  out["response_error_name"] = @response_error_name unless @response_error_name.nil?
  out
end