Class: Merge::Hris::TimesheetEntryRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/hris/types/timesheet_entry_request.rb

Overview

# The Timesheet Entry Object

### Description
The `Timesheet Entry` object is used to track coverage for hours worked by an
'Employee'.
### Usage Example
GET and POST Timesheet Entries

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(employee: OMIT, hours_worked: OMIT, start_time: OMIT, end_time: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) ⇒ Merge::Hris::TimesheetEntryRequest

Parameters:

  • employee (String) (defaults to: OMIT)

    The employee the timesheet entry is for.

  • hours_worked (Float) (defaults to: OMIT)

    The number of hours logged by the employee.

  • start_time (DateTime) (defaults to: OMIT)

    The time at which the employee started work.

  • end_time (DateTime) (defaults to: OMIT)

    The time at which the employee ended work.

  • 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



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/merge_ruby_client/hris/types/timesheet_entry_request.rb', line 44

def initialize(employee: OMIT, hours_worked: OMIT, start_time: OMIT, end_time: OMIT, integration_params: OMIT,
               linked_account_params: OMIT, additional_properties: nil)
  @employee = employee if employee != OMIT
  @hours_worked = hours_worked if hours_worked != 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,
    "hours_worked": hours_worked,
    "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



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

def additional_properties
  @additional_properties
end

#employeeString (readonly)

Returns The employee the timesheet entry is for.

Returns:

  • (String)

    The employee the timesheet entry is for.



17
18
19
# File 'lib/merge_ruby_client/hris/types/timesheet_entry_request.rb', line 17

def employee
  @employee
end

#end_timeDateTime (readonly)

Returns The time at which the employee ended work.

Returns:

  • (DateTime)

    The time at which the employee ended work.



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

def end_time
  @end_time
end

#hours_workedFloat (readonly)

Returns The number of hours logged by the employee.

Returns:

  • (Float)

    The number of hours logged by the employee.



19
20
21
# File 'lib/merge_ruby_client/hris/types/timesheet_entry_request.rb', line 19

def hours_worked
  @hours_worked
end

#integration_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


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

def integration_params
  @integration_params
end

#linked_account_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


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

def 
  @linked_account_params
end

#start_timeDateTime (readonly)

Returns The time at which the employee started work.

Returns:

  • (DateTime)

    The time at which the employee started work.



21
22
23
# File 'lib/merge_ruby_client/hris/types/timesheet_entry_request.rb', line 21

def start_time
  @start_time
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Hris::TimesheetEntryRequest

Deserialize a JSON object to an instance of TimesheetEntryRequest

Parameters:

  • json_object (String)

Returns:



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/merge_ruby_client/hris/types/timesheet_entry_request.rb', line 69

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  employee = parsed_json["employee"]
  hours_worked = parsed_json["hours_worked"]
  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,
    hours_worked: hours_worked,
    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)


102
103
104
105
106
107
108
109
# File 'lib/merge_ruby_client/hris/types/timesheet_entry_request.rb', line 102

def self.validate_raw(obj:)
  obj.employee&.is_a?(String) != false || raise("Passed value for field obj.employee is not the expected type, validation failed.")
  obj.hours_worked&.is_a?(Float) != false || raise("Passed value for field obj.hours_worked 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 TimesheetEntryRequest to a JSON object

Returns:

  • (String)


92
93
94
# File 'lib/merge_ruby_client/hris/types/timesheet_entry_request.rb', line 92

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