Class: Vapi::TimeRange

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step: OMIT, start: OMIT, end_: OMIT, timezone: OMIT, additional_properties: nil) ⇒ Vapi::TimeRange

Parameters:

  • step (Vapi::TimeRangeStep) (defaults to: OMIT)

    This is the time step for aggregations. If not provided, defaults to returning for the entire time range.

  • start (DateTime) (defaults to: OMIT)

    This is the start date for the time range. If not provided, defaults to the 7 days ago.

  • end_ (DateTime) (defaults to: OMIT)

    This is the end date for the time range. If not provided, defaults to now.

  • timezone (String) (defaults to: OMIT)

    This is the timezone you want to set for the query. If not provided, defaults to UTC.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(step: OMIT, start: OMIT, end_: OMIT, timezone: OMIT, additional_properties: nil)
  @step = step if step != OMIT
  @start = start if start != OMIT
  @end_ = end_ if end_ != OMIT
  @timezone = timezone if timezone != OMIT
  @additional_properties = additional_properties
  @_field_set = { "step": step, "start": start, "end": end_, "timezone": timezone }.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/time_range.rb', line 23

def additional_properties
  @additional_properties
end

#end_DateTime (readonly)

Returns This is the end date for the time range. If not provided, defaults to now.

Returns:

  • (DateTime)

    This is the end date for the time range. If not provided, defaults to now.



18
19
20
# File 'lib/vapi_server_sdk/types/time_range.rb', line 18

def end_
  @end_
end

#startDateTime (readonly)

Returns This is the start date for the time range. If not provided, defaults to the 7 days ago.

Returns:

  • (DateTime)

    This is the start date for the time range. If not provided, defaults to the 7 days ago.



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

def start
  @start
end

#stepVapi::TimeRangeStep (readonly)

Returns This is the time step for aggregations. If not provided, defaults to returning for the entire time range.

Returns:

  • (Vapi::TimeRangeStep)

    This is the time step for aggregations. If not provided, defaults to returning for the entire time range.



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

def step
  @step
end

#timezoneString (readonly)

Returns This is the timezone you want to set for the query. If not provided, defaults to UTC.

Returns:

  • (String)

    This is the timezone you want to set for the query. If not provided, defaults to UTC.



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

def timezone
  @timezone
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::TimeRange

Deserialize a JSON object to an instance of TimeRange

Parameters:

  • json_object (String)

Returns:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vapi_server_sdk/types/time_range.rb', line 55

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  step = parsed_json["step"]
  start = (DateTime.parse(parsed_json["start"]) unless parsed_json["start"].nil?)
  end_ = (DateTime.parse(parsed_json["end"]) unless parsed_json["end"].nil?)
  timezone = parsed_json["timezone"]
  new(
    step: step,
    start: start,
    end_: end_,
    timezone: timezone,
    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)


84
85
86
87
88
89
# File 'lib/vapi_server_sdk/types/time_range.rb', line 84

def self.validate_raw(obj:)
  obj.step&.is_a?(Vapi::TimeRangeStep) != false || raise("Passed value for field obj.step is not the expected type, validation failed.")
  obj.start&.is_a?(DateTime) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
  obj.end_&.is_a?(DateTime) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
  obj.timezone&.is_a?(String) != false || raise("Passed value for field obj.timezone is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of TimeRange to a JSON object

Returns:

  • (String)


74
75
76
# File 'lib/vapi_server_sdk/types/time_range.rb', line 74

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