Class: Vapi::PaginationMeta

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/pagination_meta.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items_per_page:, total_items:, current_page:, additional_properties: nil) ⇒ Vapi::PaginationMeta

Parameters:

  • items_per_page (Float)
  • total_items (Float)
  • current_page (Float)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



27
28
29
30
31
32
33
# File 'lib/vapi_server_sdk/types/pagination_meta.rb', line 27

def initialize(items_per_page:, total_items:, current_page:, additional_properties: nil)
  @items_per_page = items_per_page
  @total_items = total_items
  @current_page = current_page
  @additional_properties = additional_properties
  @_field_set = { "itemsPerPage": items_per_page, "totalItems": total_items, "currentPage": current_page }
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



15
16
17
# File 'lib/vapi_server_sdk/types/pagination_meta.rb', line 15

def additional_properties
  @additional_properties
end

#current_pageFloat (readonly)

Returns:

  • (Float)


13
14
15
# File 'lib/vapi_server_sdk/types/pagination_meta.rb', line 13

def current_page
  @current_page
end

#items_per_pageFloat (readonly)

Returns:

  • (Float)


9
10
11
# File 'lib/vapi_server_sdk/types/pagination_meta.rb', line 9

def items_per_page
  @items_per_page
end

#total_itemsFloat (readonly)

Returns:

  • (Float)


11
12
13
# File 'lib/vapi_server_sdk/types/pagination_meta.rb', line 11

def total_items
  @total_items
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::PaginationMeta

Deserialize a JSON object to an instance of PaginationMeta

Parameters:

  • json_object (String)

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/vapi_server_sdk/types/pagination_meta.rb', line 39

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  items_per_page = parsed_json["itemsPerPage"]
  total_items = parsed_json["totalItems"]
  current_page = parsed_json["currentPage"]
  new(
    items_per_page: items_per_page,
    total_items: total_items,
    current_page: current_page,
    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)


66
67
68
69
70
# File 'lib/vapi_server_sdk/types/pagination_meta.rb', line 66

def self.validate_raw(obj:)
  obj.items_per_page.is_a?(Float) != false || raise("Passed value for field obj.items_per_page is not the expected type, validation failed.")
  obj.total_items.is_a?(Float) != false || raise("Passed value for field obj.total_items is not the expected type, validation failed.")
  obj.current_page.is_a?(Float) != false || raise("Passed value for field obj.current_page is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PaginationMeta to a JSON object

Returns:

  • (String)


56
57
58
# File 'lib/vapi_server_sdk/types/pagination_meta.rb', line 56

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