Class: VitableConnect::Employees::Client
- Inherits:
-
Object
- Object
- VitableConnect::Employees::Client
- Defined in:
- lib/VitableConnect/employees/client.rb
Instance Method Summary collapse
-
#get(request_options: {}, **params) ⇒ VitableConnect::Types::EmployeeResponse
Retrieves detailed information for a specific employee by ID.
- #initialize(client:) ⇒ void constructor
-
#list_enrollments(request_options: {}, **params) ⇒ VitableConnect::Types::EnrollmentListResponse
Retrieves a paginated list of benefit enrollments for an employee.
-
#update(request_options: {}, **params) ⇒ VitableConnect::Types::EmployeeResponse
Updates employee personal, contact, address, and employment fields.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/VitableConnect/employees/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#get(request_options: {}, **params) ⇒ VitableConnect::Types::EmployeeResponse
Retrieves detailed information for a specific employee by ID. Returns employee details including personal information, employment status, classification and compensation-type effective dates, compensation type, and payroll deductions from the most recent statement period. Deductions reflect a snapshot of the current period and are replaced when a new statement is generated.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/VitableConnect/employees/client.rb', line 31 def get(request_options: {}, **params) params = VitableConnect::Internal::Types::Utils.normalize_keys(params) request = VitableConnect::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v1/employees/#{URI.encode_uri_component(params[:employee_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise VitableConnect::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) VitableConnect::Types::EmployeeResponse.load(response.body) else error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_enrollments(request_options: {}, **params) ⇒ VitableConnect::Types::EnrollmentListResponse
Retrieves a paginated list of benefit enrollments for an employee.
124 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 |
# File 'lib/VitableConnect/employees/client.rb', line 124 def list_enrollments(request_options: {}, **params) params = VitableConnect::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["limit"] = params[:limit] if params.key?(:limit) query_params["page"] = params[:page] if params.key?(:page) VitableConnect::Internal::OffsetItemIterator.new( initial_page: query_params["page"], item_field: :data, has_next_field: nil, step: false ) do |next_page| query_params["page"] = next_page request = VitableConnect::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v1/employees/#{URI.encode_uri_component(params[:employee_id].to_s)}/enrollments", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise VitableConnect::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) parsed_response = VitableConnect::Types::EnrollmentListResponse.load(response.body) [parsed_response, response] else error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end end |
#update(request_options: {}, **params) ⇒ VitableConnect::Types::EmployeeResponse
Updates employee personal, contact, address, and employment fields. This endpoint currently supports email, phone, gender, address, employee_class, start_date, and compensation_type. effective_date is required and applies to employee_class and compensation_type when those fields are included in the request.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/VitableConnect/employees/client.rb', line 76 def update(request_options: {}, **params) params = VitableConnect::Internal::Types::Utils.normalize_keys(params) request_data = VitableConnect::Employees::Types::PatchedUpdateEmployeeRequest.new(params).to_h non_body_param_names = %w[employee_id] body = request_data.except(*non_body_param_names) request = VitableConnect::Internal::JSON::Request.new( base_url: [:base_url], method: "PATCH", path: "v1/employees/#{URI.encode_uri_component(params[:employee_id].to_s)}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise VitableConnect::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) VitableConnect::Types::EmployeeResponse.load(response.body) else error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |