Class: Vapi::AnalyticsQuery

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table:, name:, operations:, group_by: OMIT, time_range: OMIT, additional_properties: nil) ⇒ Vapi::AnalyticsQuery

Parameters:

  • table (String)

    This is the table you want to query.

  • group_by (Array<Vapi::AnalyticsQueryGroupByItem>) (defaults to: OMIT)

    This is the list of columns you want to group by.

  • name (String)

    This is the name of the query. This will be used to identify the query in the response.

  • time_range (Vapi::TimeRange) (defaults to: OMIT)

    This is the time range for the query.

  • operations (Array<Vapi::AnalyticsOperation>)

    This is the list of operations you want to perform.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(table:, name:, operations:, group_by: OMIT, time_range: OMIT, additional_properties: nil)
  @table = table
  @group_by = group_by if group_by != OMIT
  @name = name
  @time_range = time_range if time_range != OMIT
  @operations = operations
  @additional_properties = additional_properties
  @_field_set = {
    "table": table,
    "groupBy": group_by,
    "name": name,
    "timeRange": time_range,
    "operations": operations
  }.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



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

def additional_properties
  @additional_properties
end

#group_byArray<Vapi::AnalyticsQueryGroupByItem> (readonly)

Returns This is the list of columns you want to group by.

Returns:



14
15
16
# File 'lib/vapi_server_sdk/types/analytics_query.rb', line 14

def group_by
  @group_by
end

#nameString (readonly)

Returns This is the name of the query. This will be used to identify the query in the response.

Returns:

  • (String)

    This is the name of the query. This will be used to identify the query in the response.



17
18
19
# File 'lib/vapi_server_sdk/types/analytics_query.rb', line 17

def name
  @name
end

#operationsArray<Vapi::AnalyticsOperation> (readonly)

Returns This is the list of operations you want to perform.

Returns:



21
22
23
# File 'lib/vapi_server_sdk/types/analytics_query.rb', line 21

def operations
  @operations
end

#tableString (readonly)

Returns This is the table you want to query.

Returns:

  • (String)

    This is the table you want to query.



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

def table
  @table
end

#time_rangeVapi::TimeRange (readonly)

Returns This is the time range for the query.

Returns:



19
20
21
# File 'lib/vapi_server_sdk/types/analytics_query.rb', line 19

def time_range
  @time_range
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::AnalyticsQuery

Deserialize a JSON object to an instance of AnalyticsQuery

Parameters:

  • json_object (String)

Returns:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/vapi_server_sdk/types/analytics_query.rb', line 60

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  table = parsed_json["table"]
  group_by = parsed_json["groupBy"]
  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
  operations = parsed_json["operations"]&.map do |item|
    item = item.to_json
    Vapi::AnalyticsOperation.from_json(json_object: item)
  end
  new(
    table: table,
    group_by: group_by,
    name: name,
    time_range: time_range,
    operations: operations,
    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)


99
100
101
102
103
104
105
# File 'lib/vapi_server_sdk/types/analytics_query.rb', line 99

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

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AnalyticsQuery to a JSON object

Returns:

  • (String)


89
90
91
# File 'lib/vapi_server_sdk/types/analytics_query.rb', line 89

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