Class: Merge::Hris::TimeOffRequest
- Inherits:
-
Object
- Object
- Merge::Hris::TimeOffRequest
- Defined in:
- lib/merge_ruby_client/hris/types/time_off_request.rb
Overview
# The TimeOff Object
### Description
The `TimeOff` object is used to represent all employees' Time Off entries.
### Usage Example
Fetch from the `LIST TimeOffs` endpoint and filter by `ID` to show all time off
requests.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#amount ⇒ Float
readonly
The time off quantity measured by the prescribed “units”.
-
#approver ⇒ Merge::Hris::TimeOffRequestApprover
readonly
The Merge ID of the employee with the ability to approve the time off request.
-
#employee ⇒ Merge::Hris::TimeOffRequestEmployee
readonly
The employee requesting time off.
-
#employee_note ⇒ String
readonly
The employee note for this time off request.
-
#end_time ⇒ DateTime
readonly
The day and time of the end of the time requested off.
- #integration_params ⇒ Hash{String => Object} readonly
- #linked_account_params ⇒ Hash{String => Object} readonly
-
#request_type ⇒ Merge::Hris::RequestTypeEnum
readonly
The type of time off request.
-
#start_time ⇒ DateTime
readonly
The day and time of the start of the time requested off.
-
#status ⇒ Merge::Hris::TimeOffStatusEnum
readonly
The status of this time off request.
-
#units ⇒ Merge::Hris::UnitsEnum
readonly
The measurement that the third-party integration uses to count time requested.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Hris::TimeOffRequest
Deserialize a JSON object to an instance of TimeOffRequest.
-
.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(employee: OMIT, approver: OMIT, status: OMIT, employee_note: OMIT, units: OMIT, amount: OMIT, request_type: OMIT, start_time: OMIT, end_time: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) ⇒ Merge::Hris::TimeOffRequest constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of TimeOffRequest to a JSON object.
Constructor Details
#initialize(employee: OMIT, approver: OMIT, status: OMIT, employee_note: OMIT, units: OMIT, amount: OMIT, request_type: OMIT, start_time: OMIT, end_time: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) ⇒ Merge::Hris::TimeOffRequest
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 90 def initialize(employee: OMIT, approver: OMIT, status: OMIT, employee_note: OMIT, units: OMIT, amount: OMIT, request_type: OMIT, start_time: OMIT, end_time: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) @employee = employee if employee != OMIT @approver = approver if approver != OMIT @status = status if status != OMIT @employee_note = employee_note if employee_note != OMIT @units = units if units != OMIT @amount = amount if amount != OMIT @request_type = request_type if request_type != OMIT @start_time = start_time if start_time != OMIT @end_time = end_time if end_time != OMIT @integration_params = integration_params if integration_params != OMIT @linked_account_params = linked_account_params if linked_account_params != OMIT @additional_properties = additional_properties @_field_set = { "employee": employee, "approver": approver, "status": status, "employee_note": employee_note, "units": units, "amount": amount, "request_type": request_type, "start_time": start_time, "end_time": end_time, "integration_params": integration_params, "linked_account_params": linked_account_params }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
57 58 59 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 57 def additional_properties @additional_properties end |
#amount ⇒ Float (readonly)
Returns The time off quantity measured by the prescribed “units”.
39 40 41 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 39 def amount @amount end |
#approver ⇒ Merge::Hris::TimeOffRequestApprover (readonly)
Returns The Merge ID of the employee with the ability to approve the time off request.
24 25 26 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 24 def approver @approver end |
#employee ⇒ Merge::Hris::TimeOffRequestEmployee (readonly)
Returns The employee requesting time off.
22 23 24 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 22 def employee @employee end |
#employee_note ⇒ String (readonly)
Returns The employee note for this time off request.
33 34 35 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 33 def employee_note @employee_note end |
#end_time ⇒ DateTime (readonly)
Returns The day and time of the end of the time requested off.
51 52 53 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 51 def end_time @end_time end |
#integration_params ⇒ Hash{String => Object} (readonly)
53 54 55 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 53 def integration_params @integration_params end |
#linked_account_params ⇒ Hash{String => Object} (readonly)
55 56 57 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 55 def linked_account_params @linked_account_params end |
#request_type ⇒ Merge::Hris::RequestTypeEnum (readonly)
Returns The type of time off request.
-
‘VACATION` - VACATION
-
‘SICK` - SICK
-
‘PERSONAL` - PERSONAL
-
‘JURY_DUTY` - JURY_DUTY
-
‘VOLUNTEER` - VOLUNTEER
-
‘BEREAVEMENT` - BEREAVEMENT.
47 48 49 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 47 def request_type @request_type end |
#start_time ⇒ DateTime (readonly)
Returns The day and time of the start of the time requested off.
49 50 51 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 49 def start_time @start_time end |
#status ⇒ Merge::Hris::TimeOffStatusEnum (readonly)
Returns The status of this time off request.
-
‘REQUESTED` - REQUESTED
-
‘APPROVED` - APPROVED
-
‘DECLINED` - DECLINED
-
‘CANCELLED` - CANCELLED
-
‘DELETED` - DELETED.
31 32 33 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 31 def status @status end |
#units ⇒ Merge::Hris::UnitsEnum (readonly)
Returns The measurement that the third-party integration uses to count time requested.
-
‘HOURS` - HOURS
-
‘DAYS` - DAYS.
37 38 39 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 37 def units @units end |
Class Method Details
.from_json(json_object:) ⇒ Merge::Hris::TimeOffRequest
Deserialize a JSON object to an instance of TimeOffRequest
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 125 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["employee"].nil? employee = nil else employee = parsed_json["employee"].to_json employee = Merge::Hris::TimeOffRequestEmployee.from_json(json_object: employee) end if parsed_json["approver"].nil? approver = nil else approver = parsed_json["approver"].to_json approver = Merge::Hris::TimeOffRequestApprover.from_json(json_object: approver) end status = parsed_json["status"] employee_note = parsed_json["employee_note"] units = parsed_json["units"] amount = parsed_json["amount"] request_type = parsed_json["request_type"] start_time = (DateTime.parse(parsed_json["start_time"]) unless parsed_json["start_time"].nil?) end_time = (DateTime.parse(parsed_json["end_time"]) unless parsed_json["end_time"].nil?) integration_params = parsed_json["integration_params"] linked_account_params = parsed_json["linked_account_params"] new( employee: employee, approver: approver, status: status, employee_note: employee_note, units: units, amount: amount, request_type: request_type, start_time: start_time, end_time: end_time, integration_params: integration_params, linked_account_params: linked_account_params, 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.
178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 178 def self.validate_raw(obj:) obj.employee.nil? || Merge::Hris::TimeOffRequestEmployee.validate_raw(obj: obj.employee) obj.approver.nil? || Merge::Hris::TimeOffRequestApprover.validate_raw(obj: obj.approver) obj.status&.is_a?(Merge::Hris::TimeOffStatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.employee_note&.is_a?(String) != false || raise("Passed value for field obj.employee_note is not the expected type, validation failed.") obj.units&.is_a?(Merge::Hris::UnitsEnum) != false || raise("Passed value for field obj.units is not the expected type, validation failed.") obj.amount&.is_a?(Float) != false || raise("Passed value for field obj.amount is not the expected type, validation failed.") obj.request_type&.is_a?(Merge::Hris::RequestTypeEnum) != false || raise("Passed value for field obj.request_type is not the expected type, validation failed.") obj.start_time&.is_a?(DateTime) != false || raise("Passed value for field obj.start_time is not the expected type, validation failed.") obj.end_time&.is_a?(DateTime) != false || raise("Passed value for field obj.end_time is not the expected type, validation failed.") obj.integration_params&.is_a?(Hash) != false || raise("Passed value for field obj.integration_params is not the expected type, validation failed.") obj.linked_account_params&.is_a?(Hash) != false || raise("Passed value for field obj.linked_account_params is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of TimeOffRequest to a JSON object
168 169 170 |
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 168 def to_json(*_args) @_field_set&.to_json end |