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 (Merge::Hris::TimesheetEntryRequestEmployee) (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



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

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
   =  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



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

def additional_properties
  @additional_properties
end

#employeeMerge::Hris::TimesheetEntryRequestEmployee (readonly)

Returns The employee the timesheet entry is for.

Returns:



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

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.



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

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.



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

def hours_worked
  @hours_worked
end

#integration_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


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

def integration_params
  @integration_params
end

#linked_account_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


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

def 
  
end

#start_timeDateTime (readonly)

Returns The time at which the employee started work.

Returns:

  • (DateTime)

    The time at which the employee started work.



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

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:



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

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::TimesheetEntryRequestEmployee.from_json(json_object: employee)
  end
  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)


108
109
110
111
112
113
114
115
# File 'lib/merge_ruby_client/hris/types/timesheet_entry_request.rb', line 108

def self.validate_raw(obj:)
  obj.employee.nil? || Merge::Hris::TimesheetEntryRequestEmployee.validate_raw(obj: obj.employee)
  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)


98
99
100
# File 'lib/merge_ruby_client/hris/types/timesheet_entry_request.rb', line 98

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