Class: Vellum::PaginatedSlimDocumentList
- Inherits:
-
Object
- Object
- Vellum::PaginatedSlimDocumentList
- Defined in:
- lib/vellum_ai/types/paginated_slim_document_list.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#next_ ⇒ Object
readonly
Returns the value of attribute next_.
-
#previous ⇒ Object
readonly
Returns the value of attribute previous.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ PaginatedSlimDocumentList
Deserialize a JSON object to an instance of PaginatedSlimDocumentList.
-
.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.
Instance Method Summary collapse
- #initialize(count: nil, next_: nil, previous: nil, results: nil, additional_properties: nil) ⇒ PaginatedSlimDocumentList constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of PaginatedSlimDocumentList to a JSON object.
Constructor Details
#initialize(count: nil, next_: nil, previous: nil, results: nil, additional_properties: nil) ⇒ PaginatedSlimDocumentList
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vellum_ai/types/paginated_slim_document_list.rb', line 16 def initialize(count: nil, next_: nil, previous: nil, results: nil, additional_properties: nil) # @type [Integer] @count = count # @type [String] @next_ = next_ # @type [String] @previous = previous # @type [Array<SlimDocument>] @results = results # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
8 9 10 |
# File 'lib/vellum_ai/types/paginated_slim_document_list.rb', line 8 def additional_properties @additional_properties end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
8 9 10 |
# File 'lib/vellum_ai/types/paginated_slim_document_list.rb', line 8 def count @count end |
#next_ ⇒ Object (readonly)
Returns the value of attribute next_.
8 9 10 |
# File 'lib/vellum_ai/types/paginated_slim_document_list.rb', line 8 def next_ @next_ end |
#previous ⇒ Object (readonly)
Returns the value of attribute previous.
8 9 10 |
# File 'lib/vellum_ai/types/paginated_slim_document_list.rb', line 8 def previous @previous end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
8 9 10 |
# File 'lib/vellum_ai/types/paginated_slim_document_list.rb', line 8 def results @results end |
Class Method Details
.from_json(json_object:) ⇒ PaginatedSlimDocumentList
Deserialize a JSON object to an instance of PaginatedSlimDocumentList
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vellum_ai/types/paginated_slim_document_list.rb', line 33 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) count = struct.count next_ = struct.next previous = struct.previous results = parsed_json["results"].map do |v| v = v.to_json SlimDocument.from_json(json_object: v) end new(count: count, next_: next_, previous: previous, results: 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.
57 58 59 60 61 62 |
# File 'lib/vellum_ai/types/paginated_slim_document_list.rb', line 57 def self.validate_raw(obj:) obj.count&.is_a?(Integer) != false || raise("Passed value for field obj.count is not the expected type, validation failed.") obj.next_&.is_a?(String) != false || raise("Passed value for field obj.next_ is not the expected type, validation failed.") obj.previous&.is_a?(String) != false || raise("Passed value for field obj.previous 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.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of PaginatedSlimDocumentList to a JSON object
49 50 51 |
# File 'lib/vellum_ai/types/paginated_slim_document_list.rb', line 49 def to_json(*_args) { "count": @count, "next": @next_, "previous": @previous, "results": @results }.to_json end |