Class: Kentico::Kontent::Delivery::Responses::ResponseBase

Inherits:
Object
  • Object
show all
Defined in:
lib/delivery/responses/response_base.rb

Overview

Base class for all responses from a Kentico::Kontent::Delivery::DeliveryQuery.execute call.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_code, message, json = '') ⇒ ResponseBase

Constructor.

  • Args:

    • http_code (integer) The status code returned by the REST request

    • message (string) An informative message about the response, visible when calling to_s

    • json (string) optional The complete, unmodified JSON response from the server



18
19
20
21
22
# File 'lib/delivery/responses/response_base.rb', line 18

def initialize(http_code, message, json = '')
  self.http_code = http_code
  self.message = message
  self.json = json
end

Instance Attribute Details

#http_codeObject

Returns the value of attribute http_code.



8
9
10
# File 'lib/delivery/responses/response_base.rb', line 8

def http_code
  @http_code
end

#jsonObject

Returns the value of attribute json.



8
9
10
# File 'lib/delivery/responses/response_base.rb', line 8

def json
  @json
end

#messageObject

Returns the value of attribute message.



8
9
10
# File 'lib/delivery/responses/response_base.rb', line 8

def message
  @message
end

Instance Method Details

#to_sObject

Provides an informative message about the success of the request by combining the status code and message.

  • Returns:

    • string



29
30
31
# File 'lib/delivery/responses/response_base.rb', line 29

def to_s
  "Response is status code #{http_code} with message:\n#{message}"
end