Class: TmdbApiClient::AccountTvRecommendationsResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/tmdb_ryanstep/types/account_tv_recommendations_response.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page: OMIT, results: OMIT, total_pages: OMIT, total_results: OMIT, additional_properties: nil) ⇒ TmdbApiClient::AccountTvRecommendationsResponse

Parameters:

  • page (Integer) (defaults to: OMIT)
  • results (Array<TmdbApiClient::AccountTvRecommendationsResponseResultsItem>) (defaults to: OMIT)
  • total_pages (Integer) (defaults to: OMIT)
  • total_results (Integer) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/tmdb_ryanstep/types/account_tv_recommendations_response.rb', line 31

def initialize(page: OMIT, results: OMIT, total_pages: OMIT, total_results: OMIT, additional_properties: nil)
  @page = page if page != OMIT
  @results = results if results != OMIT
  @total_pages = total_pages if total_pages != OMIT
  @total_results = total_results if total_results != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "page": page,
    "results": results,
    "total_pages": total_pages,
    "total_results": total_results
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



18
19
20
# File 'lib/tmdb_ryanstep/types/account_tv_recommendations_response.rb', line 18

def additional_properties
  @additional_properties
end

#pageInteger (readonly)

Returns:

  • (Integer)


10
11
12
# File 'lib/tmdb_ryanstep/types/account_tv_recommendations_response.rb', line 10

def page
  @page
end

#resultsArray<TmdbApiClient::AccountTvRecommendationsResponseResultsItem> (readonly)



12
13
14
# File 'lib/tmdb_ryanstep/types/account_tv_recommendations_response.rb', line 12

def results
  @results
end

#total_pagesInteger (readonly)

Returns:

  • (Integer)


14
15
16
# File 'lib/tmdb_ryanstep/types/account_tv_recommendations_response.rb', line 14

def total_pages
  @total_pages
end

#total_resultsInteger (readonly)

Returns:

  • (Integer)


16
17
18
# File 'lib/tmdb_ryanstep/types/account_tv_recommendations_response.rb', line 16

def total_results
  @total_results
end

Class Method Details

.from_json(json_object:) ⇒ TmdbApiClient::AccountTvRecommendationsResponse

Deserialize a JSON object to an instance of AccountTvRecommendationsResponse

Parameters:

  • json_object (String)

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/tmdb_ryanstep/types/account_tv_recommendations_response.rb', line 51

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  page = parsed_json["page"]
  results = parsed_json["results"]&.map do |item|
    item = item.to_json
    TmdbApiClient::AccountTvRecommendationsResponseResultsItem.from_json(json_object: item)
  end
  total_pages = parsed_json["total_pages"]
  total_results = parsed_json["total_results"]
  new(
    page: page,
    results: results,
    total_pages: total_pages,
    total_results: total_results,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


83
84
85
86
87
88
# File 'lib/tmdb_ryanstep/types/account_tv_recommendations_response.rb', line 83

def self.validate_raw(obj:)
  obj.page&.is_a?(Integer) != false || raise("Passed value for field obj.page is not the expected type, validation failed.")
  obj.results&.is_a?(Array) != false || raise("Passed value for field obj.results is not the expected type, validation failed.")
  obj.total_pages&.is_a?(Integer) != false || raise("Passed value for field obj.total_pages is not the expected type, validation failed.")
  obj.total_results&.is_a?(Integer) != false || raise("Passed value for field obj.total_results is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AccountTvRecommendationsResponse to a JSON object

Returns:

  • (String)


73
74
75
# File 'lib/tmdb_ryanstep/types/account_tv_recommendations_response.rb', line 73

def to_json(*_args)
  @_field_set&.to_json
end