Class: Gusto::Payrolls::PayPeriod

Inherits:
Object
  • Object
show all
Defined in:
lib/fern_gusto/payrolls/types/pay_period.rb

Overview

The representation of a pay period.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_date: OMIT, end_date: OMIT, pay_schedule_uuid: OMIT, payroll: OMIT, additional_properties: nil) ⇒ Gusto::Payrolls::PayPeriod

Parameters:

  • start_date (String) (defaults to: OMIT)

    The start date, inclusive, of the pay period.

  • end_date (String) (defaults to: OMIT)

    The end date, inclusive, of the pay period.

  • pay_schedule_uuid (String) (defaults to: OMIT)

    A unique identifier of the pay schedule to which the pay period belongs.

  • payroll (Gusto::Payrolls::PayPeriodPayroll) (defaults to: OMIT)

    Information about the payroll for the pay period.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



32
33
34
35
36
37
38
39
40
41
# File 'lib/fern_gusto/payrolls/types/pay_period.rb', line 32

def initialize(start_date: OMIT, end_date: OMIT, pay_schedule_uuid: OMIT, payroll: OMIT, additional_properties: nil)
  @start_date = start_date if start_date != OMIT
  @end_date = end_date if end_date != OMIT
  @pay_schedule_uuid = pay_schedule_uuid if pay_schedule_uuid != OMIT
  @payroll = payroll if payroll != OMIT
  @additional_properties = additional_properties
  @_field_set = { "start_date": start_date, "end_date": end_date, "pay_schedule_uuid": pay_schedule_uuid, "payroll": payroll }.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



19
20
21
# File 'lib/fern_gusto/payrolls/types/pay_period.rb', line 19

def additional_properties
  @additional_properties
end

#end_dateString (readonly)

Returns The end date, inclusive, of the pay period.

Returns:

  • (String)

    The end date, inclusive, of the pay period.



13
14
15
# File 'lib/fern_gusto/payrolls/types/pay_period.rb', line 13

def end_date
  @end_date
end

#pay_schedule_uuidString (readonly)

Returns A unique identifier of the pay schedule to which the pay period belongs.

Returns:

  • (String)

    A unique identifier of the pay schedule to which the pay period belongs.



15
16
17
# File 'lib/fern_gusto/payrolls/types/pay_period.rb', line 15

def pay_schedule_uuid
  @pay_schedule_uuid
end

#payrollGusto::Payrolls::PayPeriodPayroll (readonly)

Returns Information about the payroll for the pay period.

Returns:



17
18
19
# File 'lib/fern_gusto/payrolls/types/pay_period.rb', line 17

def payroll
  @payroll
end

#start_dateString (readonly)

Returns The start date, inclusive, of the pay period.

Returns:

  • (String)

    The start date, inclusive, of the pay period.



11
12
13
# File 'lib/fern_gusto/payrolls/types/pay_period.rb', line 11

def start_date
  @start_date
end

Class Method Details

.from_json(json_object:) ⇒ Gusto::Payrolls::PayPeriod

Parameters:

  • json_object (String)

Returns:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fern_gusto/payrolls/types/pay_period.rb', line 46

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  start_date = parsed_json["start_date"]
  end_date = parsed_json["end_date"]
  pay_schedule_uuid = parsed_json["pay_schedule_uuid"]
  unless parsed_json["payroll"].nil?
    payroll = parsed_json["payroll"].to_json
    payroll = Gusto::Payrolls::PayPeriodPayroll.from_json(json_object: payroll)
  else
    payroll = nil
  end
  new(
    start_date: start_date,
    end_date: end_date,
    pay_schedule_uuid: pay_schedule_uuid,
    payroll: payroll,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


78
79
80
81
82
83
# File 'lib/fern_gusto/payrolls/types/pay_period.rb', line 78

def self.validate_raw(obj:)
  obj.start_date&.is_a?(String) != false || raise("Passed value for field obj.start_date is not the expected type, validation failed.")
  obj.end_date&.is_a?(String) != false || raise("Passed value for field obj.end_date is not the expected type, validation failed.")
  obj.pay_schedule_uuid&.is_a?(String) != false || raise("Passed value for field obj.pay_schedule_uuid is not the expected type, validation failed.")
  obj.payroll.nil? || Gusto::Payrolls::PayPeriodPayroll.validate_raw(obj: obj.payroll)
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


69
70
71
# File 'lib/fern_gusto/payrolls/types/pay_period.rb', line 69

def to_json
  @_field_set&.to_json
end