Class: Merge::Hris::TimeOff
- Inherits:
-
Object
- Object
- Merge::Hris::TimeOff
- Defined in:
- lib/merge_ruby_client/hris/types/time_off.rb,
lib/merge_ruby_client/hris/time_off/types/time_off_list_request_expand.rb,
lib/merge_ruby_client/hris/time_off/types/time_off_list_request_status.rb,
lib/merge_ruby_client/hris/time_off/types/time_off_retrieve_request_expand.rb,
lib/merge_ruby_client/hris/time_off/types/time_off_list_request_request_type.rb,
lib/merge_ruby_client/hris/time_off/types/time_off_list_request_remote_fields.rb,
lib/merge_ruby_client/hris/time_off/types/time_off_list_request_show_enum_origins.rb,
lib/merge_ruby_client/hris/time_off/types/time_off_retrieve_request_remote_fields.rb,
lib/merge_ruby_client/hris/time_off/types/time_off_retrieve_request_show_enum_origins.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.
Defined Under Namespace
Classes: TimeOffListRequestExpand, TimeOffListRequestRemoteFields, TimeOffListRequestRequestType, TimeOffListRequestShowEnumOrigins, TimeOffListRequestStatus, TimeOffRetrieveRequestExpand, TimeOffRetrieveRequestRemoteFields, TimeOffRetrieveRequestShowEnumOrigins
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::TimeOffApprover
readonly
The Merge ID of the employee with the ability to approve the time off request.
-
#created_at ⇒ DateTime
readonly
The datetime that this object was created by Merge.
-
#employee ⇒ Merge::Hris::TimeOffEmployee
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.
- #field_mappings ⇒ Hash{String => Object} readonly
- #id ⇒ String readonly
-
#modified_at ⇒ DateTime
readonly
The datetime that this object was modified by Merge.
- #remote_data ⇒ Array<Merge::Hris::RemoteData> readonly
-
#remote_id ⇒ String
readonly
The third-party API ID of the matching object.
- #remote_was_deleted ⇒ Boolean 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::TimeOff
Deserialize a JSON object to an instance of TimeOff.
-
.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(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, employee: OMIT, approver: OMIT, status: OMIT, employee_note: OMIT, units: OMIT, amount: OMIT, request_type: OMIT, start_time: OMIT, end_time: OMIT, remote_was_deleted: OMIT, field_mappings: OMIT, remote_data: OMIT, additional_properties: nil) ⇒ Merge::Hris::TimeOff constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of TimeOff to a JSON object.
Constructor Details
#initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, employee: OMIT, approver: OMIT, status: OMIT, employee_note: OMIT, units: OMIT, amount: OMIT, request_type: OMIT, start_time: OMIT, end_time: OMIT, remote_was_deleted: OMIT, field_mappings: OMIT, remote_data: OMIT, additional_properties: nil) ⇒ Merge::Hris::TimeOff
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 106 def initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, employee: OMIT, approver: OMIT, status: OMIT, employee_note: OMIT, units: OMIT, amount: OMIT, request_type: OMIT, start_time: OMIT, end_time: OMIT, remote_was_deleted: OMIT, field_mappings: OMIT, remote_data: OMIT, additional_properties: nil) @id = id if id != OMIT @remote_id = remote_id if remote_id != OMIT @created_at = created_at if created_at != OMIT @modified_at = modified_at if modified_at != OMIT @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 @remote_was_deleted = remote_was_deleted if remote_was_deleted != OMIT @field_mappings = field_mappings if field_mappings != OMIT @remote_data = remote_data if remote_data != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "remote_id": remote_id, "created_at": created_at, "modified_at": modified_at, "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, "remote_was_deleted": remote_was_deleted, "field_mappings": field_mappings, "remote_data": remote_data }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
68 69 70 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 68 def additional_properties @additional_properties end |
#amount ⇒ Float (readonly)
Returns The time off quantity measured by the prescribed “units”.
48 49 50 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 48 def amount @amount end |
#approver ⇒ Merge::Hris::TimeOffApprover (readonly)
Returns The Merge ID of the employee with the ability to approve the time off request.
33 34 35 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 33 def approver @approver end |
#created_at ⇒ DateTime (readonly)
Returns The datetime that this object was created by Merge.
27 28 29 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 27 def created_at @created_at end |
#employee ⇒ Merge::Hris::TimeOffEmployee (readonly)
Returns The employee requesting time off.
31 32 33 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 31 def employee @employee end |
#employee_note ⇒ String (readonly)
Returns The employee note for this time off request.
42 43 44 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 42 def employee_note @employee_note end |
#end_time ⇒ DateTime (readonly)
Returns The day and time of the end of the time requested off.
60 61 62 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 60 def end_time @end_time end |
#field_mappings ⇒ Hash{String => Object} (readonly)
64 65 66 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 64 def field_mappings @field_mappings end |
#id ⇒ String (readonly)
23 24 25 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 23 def id @id end |
#modified_at ⇒ DateTime (readonly)
Returns The datetime that this object was modified by Merge.
29 30 31 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 29 def modified_at @modified_at end |
#remote_data ⇒ Array<Merge::Hris::RemoteData> (readonly)
66 67 68 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 66 def remote_data @remote_data end |
#remote_id ⇒ String (readonly)
Returns The third-party API ID of the matching object.
25 26 27 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 25 def remote_id @remote_id end |
#remote_was_deleted ⇒ Boolean (readonly)
62 63 64 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 62 def remote_was_deleted @remote_was_deleted 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.
56 57 58 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 56 def request_type @request_type end |
#start_time ⇒ DateTime (readonly)
Returns The day and time of the start of the time requested off.
58 59 60 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 58 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.
40 41 42 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 40 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.
46 47 48 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 46 def units @units end |
Class Method Details
.from_json(json_object:) ⇒ Merge::Hris::TimeOff
Deserialize a JSON object to an instance of TimeOff
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 151 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] remote_id = parsed_json["remote_id"] created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?) modified_at = (DateTime.parse(parsed_json["modified_at"]) unless parsed_json["modified_at"].nil?) if parsed_json["employee"].nil? employee = nil else employee = parsed_json["employee"].to_json employee = Merge::Hris::TimeOffEmployee.from_json(json_object: employee) end if parsed_json["approver"].nil? approver = nil else approver = parsed_json["approver"].to_json approver = Merge::Hris::TimeOffApprover.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?) remote_was_deleted = parsed_json["remote_was_deleted"] field_mappings = parsed_json["field_mappings"] remote_data = parsed_json["remote_data"]&.map do |item| item = item.to_json Merge::Hris::RemoteData.from_json(json_object: item) end new( id: id, remote_id: remote_id, created_at: created_at, modified_at: modified_at, 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, remote_was_deleted: remote_was_deleted, field_mappings: field_mappings, remote_data: remote_data, 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.
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 217 def self.validate_raw(obj:) obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.remote_id&.is_a?(String) != false || raise("Passed value for field obj.remote_id is not the expected type, validation failed.") obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.modified_at&.is_a?(DateTime) != false || raise("Passed value for field obj.modified_at is not the expected type, validation failed.") obj.employee.nil? || Merge::Hris::TimeOffEmployee.validate_raw(obj: obj.employee) obj.approver.nil? || Merge::Hris::TimeOffApprover.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.remote_was_deleted&.is_a?(Boolean) != false || raise("Passed value for field obj.remote_was_deleted is not the expected type, validation failed.") obj.field_mappings&.is_a?(Hash) != false || raise("Passed value for field obj.field_mappings is not the expected type, validation failed.") obj.remote_data&.is_a?(Array) != false || raise("Passed value for field obj.remote_data is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of TimeOff to a JSON object
207 208 209 |
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 207 def to_json(*_args) @_field_set&.to_json end |