Class: Vellum::ExecuteApiResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/types/execute_api_response.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_code:, text:, json: OMIT, headers:, additional_properties: nil) ⇒ Vellum::ExecuteApiResponse

Parameters:

  • status_code (Integer)
  • text (String)
  • json (Vellum::ExecuteApiResponseJson) (defaults to: OMIT)
  • headers (Hash{String => String})
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



30
31
32
33
34
35
36
37
38
39
# File 'lib/vellum_ai/types/execute_api_response.rb', line 30

def initialize(status_code:, text:, json: OMIT, headers:, additional_properties: nil)
  @status_code = status_code
  @text = text
  @json = json if json != OMIT
  @headers = headers
  @additional_properties = additional_properties
  @_field_set = { "status_code": status_code, "text": text, "json": json, "headers": headers }.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



17
18
19
# File 'lib/vellum_ai/types/execute_api_response.rb', line 17

def additional_properties
  @additional_properties
end

#headersHash{String => String} (readonly)

Returns:

  • (Hash{String => String})


15
16
17
# File 'lib/vellum_ai/types/execute_api_response.rb', line 15

def headers
  @headers
end

#jsonVellum::ExecuteApiResponseJson (readonly)



13
14
15
# File 'lib/vellum_ai/types/execute_api_response.rb', line 13

def json
  @json
end

#status_codeInteger (readonly)

Returns:

  • (Integer)


9
10
11
# File 'lib/vellum_ai/types/execute_api_response.rb', line 9

def status_code
  @status_code
end

#textString (readonly)

Returns:

  • (String)


11
12
13
# File 'lib/vellum_ai/types/execute_api_response.rb', line 11

def text
  @text
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::ExecuteApiResponse

Parameters:

  • json_object (String)

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/vellum_ai/types/execute_api_response.rb', line 44

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  status_code = parsed_json["status_code"]
  text = parsed_json["text"]
  unless parsed_json["json"].nil?
    json = parsed_json["json"].to_json
    json = Vellum::ExecuteApiResponseJson.from_json(json_object: json)
  else
    json = nil
  end
  headers = parsed_json["headers"]
  new(
    status_code: status_code,
    text: text,
    json: json,
    headers: headers,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


76
77
78
79
80
81
# File 'lib/vellum_ai/types/execute_api_response.rb', line 76

def self.validate_raw(obj:)
  obj.status_code.is_a?(Integer) != false || raise("Passed value for field obj.status_code is not the expected type, validation failed.")
  obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
  obj.json.nil? || Vellum::ExecuteApiResponseJson.validate_raw(obj: obj.json)
  obj.headers.is_a?(Hash) != false || raise("Passed value for field obj.headers is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


67
68
69
# File 'lib/vellum_ai/types/execute_api_response.rb', line 67

def to_json
  @_field_set&.to_json
end