Class: Kentico::Kontent::Delivery::Responses::DeliveryLanguageListingResponse

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

Overview

The response of a successful query for project languages.

Instance Attribute Summary

Attributes inherited from ResponseBase

#headers, #http_code, #json, #message

Instance Method Summary collapse

Methods inherited from ResponseBase

#to_s

Constructor Details

#initialize(headers, body) ⇒ DeliveryLanguageListingResponse

Returns a new instance of DeliveryLanguageListingResponse.



33
34
35
36
37
38
39
# File 'lib/delivery/responses/delivery_language_listing_response.rb', line 33

def initialize(headers, body)
  @response = JSON.parse(body)
  super 200,
        "Success, #{languages.length} languages returned",
        headers,
        JSON.generate(@response)
end

Instance Method Details

#languagesObject

Parses the ‘languages’ JSON node of the response from a Kentico::Kontent::Delivery::DeliveryClient.languages call.

  • Returns:

    • Array The content types as Kentico::Kontent::Delivery::Language objects



24
25
26
27
28
29
30
31
# File 'lib/delivery/responses/delivery_language_listing_response.rb', line 24

def languages
  @languages unless @languages.nil?
  languages = []
  @response['languages'].each do |n|
    languages << Kentico::Kontent::Delivery::Language.new(n)
  end
  @languages = languages
end

#paginationObject

Parses the ‘pagination’ JSON node of the response.

  • Returns:

    • Kentico::Kontent::Delivery::Pagination



14
15
16
17
# File 'lib/delivery/responses/delivery_language_listing_response.rb', line 14

def pagination
  @pagination unless @pagination.nil?
  @pagination = Pagination.new @response['pagination']
end