Class: Vapi::TimeRange
- Inherits:
-
Object
- Object
- Vapi::TimeRange
- Defined in:
- lib/vapi_server_sdk/types/time_range.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#end_ ⇒ DateTime
readonly
This is the end date for the time range.
-
#start ⇒ DateTime
readonly
This is the start date for the time range.
-
#step ⇒ Vapi::TimeRangeStep
readonly
This is the time step for aggregations.
-
#timezone ⇒ String
readonly
This is the timezone you want to set for the query.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::TimeRange
Deserialize a JSON object to an instance of TimeRange.
-
.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(step: OMIT, start: OMIT, end_: OMIT, timezone: OMIT, additional_properties: nil) ⇒ Vapi::TimeRange constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of TimeRange to a JSON object.
Constructor Details
#initialize(step: OMIT, start: OMIT, end_: OMIT, timezone: OMIT, additional_properties: nil) ⇒ Vapi::TimeRange
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_properties ⇒ OpenStruct (readonly)
Returns 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.
18 19 20 |
# File 'lib/vapi_server_sdk/types/time_range.rb', line 18 def end_ @end_ end |
#start ⇒ DateTime (readonly)
Returns 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 |
#step ⇒ Vapi::TimeRangeStep (readonly)
Returns 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 |
#timezone ⇒ String (readonly)
Returns 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
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.
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
74 75 76 |
# File 'lib/vapi_server_sdk/types/time_range.rb', line 74 def to_json(*_args) @_field_set&.to_json end |