Class: Vapi::AnalyticsQueryResult

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, time_range:, result:, additional_properties: nil) ⇒ Vapi::AnalyticsQueryResult

Parameters:

  • name (String)

    This is the unique key for the query.

  • time_range (Vapi::TimeRange)

    This is the time range for the query.

  • result (Array<Hash{String => Object}>)

    This is the result of the query, a list of unique groups with result of their aggregations. Example: “result”: [ { “date”: “2023-01-01”, “assistantId”: “123”, “endedReason”: “customer-ended-call”, “sumDuration”: 120, “avgCost”: 10.5 }, { “date”: “2023-01-02”, “assistantId”: “123”, “endedReason”: “customer-did-not-give-microphone-permission”, “sumDuration”: 0, “avgCost”: 0 }, // Additional results ]

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



46
47
48
49
50
51
52
# File 'lib/vapi_server_sdk/types/analytics_query_result.rb', line 46

def initialize(name:, time_range:, result:, additional_properties: nil)
  @name = name
  @time_range = time_range
  @result = result
  @additional_properties = additional_properties
  @_field_set = { "name": name, "timeRange": time_range, "result": result }
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



25
26
27
# File 'lib/vapi_server_sdk/types/analytics_query_result.rb', line 25

def additional_properties
  @additional_properties
end

#nameString (readonly)

Returns This is the unique key for the query.

Returns:

  • (String)

    This is the unique key for the query.



10
11
12
# File 'lib/vapi_server_sdk/types/analytics_query_result.rb', line 10

def name
  @name
end

#resultArray<Hash{String => Object}> (readonly)

Returns This is the result of the query, a list of unique groups with result of their aggregations. Example: “result”: [ { “date”: “2023-01-01”, “assistantId”: “123”, “endedReason”: “customer-ended-call”, “sumDuration”: 120, “avgCost”: 10.5 }, { “date”: “2023-01-02”, “assistantId”: “123”, “endedReason”: “customer-did-not-give-microphone-permission”, “sumDuration”: 0, “avgCost”: 0 }, // Additional results ].

Returns:

  • (Array<Hash{String => Object}>)

    This is the result of the query, a list of unique groups with result of their aggregations. Example: “result”: [ { “date”: “2023-01-01”, “assistantId”: “123”, “endedReason”: “customer-ended-call”, “sumDuration”: 120, “avgCost”: 10.5 }, { “date”: “2023-01-02”, “assistantId”: “123”, “endedReason”: “customer-did-not-give-microphone-permission”, “sumDuration”: 0, “avgCost”: 0 }, // Additional results ]



23
24
25
# File 'lib/vapi_server_sdk/types/analytics_query_result.rb', line 23

def result
  @result
end

#time_rangeVapi::TimeRange (readonly)

Returns This is the time range for the query.

Returns:



12
13
14
# File 'lib/vapi_server_sdk/types/analytics_query_result.rb', line 12

def time_range
  @time_range
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::AnalyticsQueryResult

Deserialize a JSON object to an instance of AnalyticsQueryResult

Parameters:

  • json_object (String)

Returns:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vapi_server_sdk/types/analytics_query_result.rb', line 58

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  name = parsed_json["name"]
  if parsed_json["timeRange"].nil?
    time_range = nil
  else
    time_range = parsed_json["timeRange"].to_json
    time_range = Vapi::TimeRange.from_json(json_object: time_range)
  end
  result = parsed_json["result"]
  new(
    name: name,
    time_range: time_range,
    result: result,
    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)


90
91
92
93
94
# File 'lib/vapi_server_sdk/types/analytics_query_result.rb', line 90

def self.validate_raw(obj:)
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  Vapi::TimeRange.validate_raw(obj: obj.time_range)
  obj.result.is_a?(Array) != false || raise("Passed value for field obj.result is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AnalyticsQueryResult to a JSON object

Returns:

  • (String)


80
81
82
# File 'lib/vapi_server_sdk/types/analytics_query_result.rb', line 80

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