Class: Merge::Hris::TimeOff

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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



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
146
147
148
149
150
151
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 112

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_propertiesOpenStruct (readonly)



71
72
73
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 71

def additional_properties
  @additional_properties
end

#amountFloat (readonly)



48
49
50
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 48

def amount
  @amount
end

#approverMerge::Hris::TimeOffApprover (readonly)



33
34
35
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 33

def approver
  @approver
end

#created_atDateTime (readonly)



27
28
29
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 27

def created_at
  @created_at
end

#employeeMerge::Hris::TimeOffEmployee (readonly)



31
32
33
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 31

def employee
  @employee
end

#employee_noteString (readonly)



42
43
44
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 42

def employee_note
  @employee_note
end

#end_timeDateTime (readonly)



60
61
62
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 60

def end_time
  @end_time
end

#field_mappingsHash{String => Object} (readonly)



67
68
69
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 67

def field_mappings
  @field_mappings
end

#idString (readonly)



23
24
25
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 23

def id
  @id
end

#modified_atDateTime (readonly)



29
30
31
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 29

def modified_at
  @modified_at
end

#remote_dataArray<Merge::Hris::RemoteData> (readonly)



69
70
71
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 69

def remote_data
  @remote_data
end

#remote_idString (readonly)



25
26
27
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 25

def remote_id
  @remote_id
end

#remote_was_deletedBoolean (readonly)



65
66
67
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 65

def remote_was_deleted
  @remote_was_deleted
end

#request_typeMerge::Hris::RequestTypeEnum (readonly)



56
57
58
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 56

def request_type
  @request_type
end

#start_timeDateTime (readonly)



58
59
60
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 58

def start_time
  @start_time
end

#statusMerge::Hris::TimeOffStatusEnum (readonly)



40
41
42
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 40

def status
  @status
end

#unitsMerge::Hris::UnitsEnum (readonly)



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



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
203
204
205
206
207
208
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 157

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.


223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 223

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



213
214
215
# File 'lib/merge_ruby_client/hris/types/time_off.rb', line 213

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