Class: Merge::Hris::TimeOffRequest

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

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:

  • employee (Merge::Hris::TimeOffRequestEmployee) (defaults to: OMIT)

    The employee requesting time off.

  • approver (Merge::Hris::TimeOffRequestApprover) (defaults to: OMIT)

    The Merge ID of the employee with the ability to approve the time off request.

  • status (Merge::Hris::TimeOffStatusEnum) (defaults to: OMIT)

    The status of this time off request.

    • ‘REQUESTED` - REQUESTED

    • ‘APPROVED` - APPROVED

    • ‘DECLINED` - DECLINED

    • ‘CANCELLED` - CANCELLED

    • ‘DELETED` - DELETED

  • employee_note (String) (defaults to: OMIT)

    The employee note for this time off request.

  • units (Merge::Hris::UnitsEnum) (defaults to: OMIT)

    The measurement that the third-party integration uses to count time requested.

    • ‘HOURS` - HOURS

    • ‘DAYS` - DAYS

  • amount (Float) (defaults to: OMIT)

    The time off quantity measured by the prescribed “units”.

  • request_type (Merge::Hris::RequestTypeEnum) (defaults to: OMIT)

    The type of time off request.

    • ‘VACATION` - VACATION

    • ‘SICK` - SICK

    • ‘PERSONAL` - PERSONAL

    • ‘JURY_DUTY` - JURY_DUTY

    • ‘VOLUNTEER` - VOLUNTEER

    • ‘BEREAVEMENT` - BEREAVEMENT

  • start_time (DateTime) (defaults to: OMIT)

    The day and time of the start of the time requested off.

  • end_time (DateTime) (defaults to: OMIT)

    The day and time of the end of the time requested off.

  • integration_params (Hash{String => Object}) (defaults to: OMIT)
  • linked_account_params (Hash{String => Object}) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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 =  if  != 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": 
  }.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



57
58
59
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 57

def additional_properties
  @additional_properties
end

#amountFloat (readonly)

Returns The time off quantity measured by the prescribed “units”.

Returns:

  • (Float)

    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

#approverMerge::Hris::TimeOffRequestApprover (readonly)

Returns The Merge ID of the employee with the ability to approve the time off request.

Returns:



24
25
26
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 24

def approver
  @approver
end

#employeeMerge::Hris::TimeOffRequestEmployee (readonly)

Returns The employee requesting time off.

Returns:



22
23
24
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 22

def employee
  @employee
end

#employee_noteString (readonly)

Returns The employee note for this time off request.

Returns:

  • (String)

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

Returns The day and time of the end of the time requested off.

Returns:

  • (DateTime)

    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_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


53
54
55
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 53

def integration_params
  @integration_params
end

#linked_account_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


55
56
57
# File 'lib/merge_ruby_client/hris/types/time_off_request.rb', line 55

def 
  @linked_account_params
end

#request_typeMerge::Hris::RequestTypeEnum (readonly)

Returns The type of time off request.

  • ‘VACATION` - VACATION

  • ‘SICK` - SICK

  • ‘PERSONAL` - PERSONAL

  • ‘JURY_DUTY` - JURY_DUTY

  • ‘VOLUNTEER` - VOLUNTEER

  • ‘BEREAVEMENT` - BEREAVEMENT.

Returns:

  • (Merge::Hris::RequestTypeEnum)

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

Returns The day and time of the start of the time requested off.

Returns:

  • (DateTime)

    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

#statusMerge::Hris::TimeOffStatusEnum (readonly)

Returns The status of this time off request.

  • ‘REQUESTED` - REQUESTED

  • ‘APPROVED` - APPROVED

  • ‘DECLINED` - DECLINED

  • ‘CANCELLED` - CANCELLED

  • ‘DELETED` - DELETED.

Returns:

  • (Merge::Hris::TimeOffStatusEnum)

    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

#unitsMerge::Hris::UnitsEnum (readonly)

Returns The measurement that the third-party integration uses to count time requested.

  • ‘HOURS` - HOURS

  • ‘DAYS` - DAYS.

Returns:

  • (Merge::Hris::UnitsEnum)

    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

Parameters:

  • json_object (String)

Returns:



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"]
   = 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: ,
    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)


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.&.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

Returns:

  • (String)


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