Class: FinchAPI::Resources::HRIS::Benefits::Individuals

Inherits:
Object
  • Object
show all
Defined in:
lib/finch_api/resources/hris/benefits/individuals.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Individuals

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Individuals.

Parameters:



124
125
126
# File 'lib/finch_api/resources/hris/benefits/individuals.rb', line 124

def initialize(client:)
  @client = client
end

Instance Method Details

#enroll_many(benefit_id, entity_ids: nil, individuals: nil, request_options: {}) ⇒ FinchAPI::Models::HRIS::Benefits::EnrolledIndividualBenefitResponse

Enroll an individual into a deduction or contribution. This is an overwrite operation. If the employee is already enrolled, the enrollment amounts will be adjusted. Making the same request multiple times will not create new enrollments, but will continue to set the state of the existing enrollment.

Parameters:

Returns:

See Also:



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/finch_api/resources/hris/benefits/individuals.rb', line 26

def enroll_many(benefit_id, params = {})
  parsed, options = FinchAPI::HRIS::Benefits::IndividualEnrollManyParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["employer/benefits/%1$s/individuals", benefit_id],
    query: parsed.except(:individuals),
    body: parsed[:individuals],
    model: FinchAPI::HRIS::Benefits::EnrolledIndividualBenefitResponse,
    options: options
  )
end

#enrolled_ids(benefit_id, entity_ids: nil, request_options: {}) ⇒ FinchAPI::Models::HRIS::Benefits::IndividualEnrolledIDsResponse

Lists individuals currently enrolled in a given deduction.

Parameters:

  • benefit_id (String)
  • entity_ids (Array<String>)

    The entity IDs to specify which entities’ data to access.

  • request_options (FinchAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



51
52
53
54
55
56
57
58
59
60
# File 'lib/finch_api/resources/hris/benefits/individuals.rb', line 51

def enrolled_ids(benefit_id, params = {})
  parsed, options = FinchAPI::HRIS::Benefits::IndividualEnrolledIDsParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["employer/benefits/%1$s/enrolled", benefit_id],
    query: parsed,
    model: FinchAPI::Models::HRIS::Benefits::IndividualEnrolledIDsResponse,
    options: options
  )
end

#retrieve_many_benefits(benefit_id, entity_ids: nil, individual_ids: nil, request_options: {}) ⇒ FinchAPI::Internal::SinglePage<FinchAPI::Models::HRIS::Benefits::IndividualBenefit>

Some parameter documentations has been truncated, see Models::HRIS::Benefits::IndividualRetrieveManyBenefitsParams for more details.

Get enrollment information for the given individuals.

Parameters:

  • benefit_id (String)
  • entity_ids (Array<String>)

    The entity IDs to specify which entities’ data to access.

  • individual_ids (String)

    comma-delimited list of stable Finch uuids for each individual. If empty, defaul

  • request_options (FinchAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/finch_api/resources/hris/benefits/individuals.rb', line 81

def retrieve_many_benefits(benefit_id, params = {})
  parsed, options = FinchAPI::HRIS::Benefits::IndividualRetrieveManyBenefitsParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["employer/benefits/%1$s/individuals", benefit_id],
    query: parsed,
    page: FinchAPI::Internal::SinglePage,
    model: FinchAPI::HRIS::Benefits::IndividualBenefit,
    options: options
  )
end

#unenroll_many(benefit_id, entity_ids: nil, individual_ids: nil, request_options: {}) ⇒ FinchAPI::Models::HRIS::Benefits::UnenrolledIndividualBenefitResponse

Unenroll individuals from a deduction or contribution

Parameters:

  • benefit_id (String)

    Path param:

  • entity_ids (Array<String>)

    Query param: The entity IDs to specify which entities’ data to access.

  • individual_ids (Array<String>)

    Body param: Array of individual_ids to unenroll.

  • request_options (FinchAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/finch_api/resources/hris/benefits/individuals.rb', line 108

def unenroll_many(benefit_id, params = {})
  parsed, options = FinchAPI::HRIS::Benefits::IndividualUnenrollManyParams.dump_request(params)
  query_params = [:entity_ids]
  @client.request(
    method: :delete,
    path: ["employer/benefits/%1$s/individuals", benefit_id],
    query: parsed.slice(*query_params),
    body: parsed.except(*query_params),
    model: FinchAPI::HRIS::Benefits::UnenrolledIndividualBenefitResponse,
    options: options
  )
end