Class: VitableConnect::Enrollments::Client
- Inherits:
-
Object
- Object
- VitableConnect::Enrollments::Client
- Defined in:
- lib/VitableConnect/enrollments/client.rb
Instance Method Summary collapse
-
#get(request_options: {}, **params) ⇒ VitableConnect::Types::EnrollmentResponse
Retrieves a single enrollment: the employee and employer it belongs to, the benefit product, its status, the coverage period, the employee payroll deduction and employer contribution, and the enrolled plan's Summary of Benefits and Coverage document when one is on file.
- #initialize(client:) ⇒ void constructor
-
#reissue(request_options: {}, **params) ⇒ VitableConnect::Types::ReissueEnrollmentResponse
Closes the targeted enrollment and creates a new unanswered enrollment for the same member and plan year.
-
#terminate(request_options: {}, **params) ⇒ untyped
Terminates enrolled coverage immediately.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/VitableConnect/enrollments/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#get(request_options: {}, **params) ⇒ VitableConnect::Types::EnrollmentResponse
Retrieves a single enrollment: the employee and employer it belongs to, the benefit product, its status, the coverage period, the employee payroll deduction and employer contribution, and the enrolled plan's Summary of Benefits and Coverage document when one is on file. An enrollment the caller cannot reach is indistinguishable from one that does not exist.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/VitableConnect/enrollments/client.rb', line 32 def get(request_options: {}, **params) params = VitableConnect::Internal::Types::Utils.normalize_keys(params) headers = {} headers["X-Vitable-Organization"] = params[:vitable_organization] if params[:vitable_organization] request = VitableConnect::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v1/enrollments/#{URI.encode_uri_component(params[:enrollment_id].to_s)}", headers: headers, 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::EnrollmentResponse.load(response.body) else error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#reissue(request_options: {}, **params) ⇒ VitableConnect::Types::ReissueEnrollmentResponse
Closes the targeted enrollment and creates a new unanswered enrollment for the same member and plan year. VPC never requires a qualifying life event; other products require an accepted, member-owned event outside open enrollment. User-backed callers must provide a reason; it is optional for organization API-key callers. Tenant mismatches return a non-disclosing 404 before the request body is validated.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/VitableConnect/enrollments/client.rb', line 82 def reissue(request_options: {}, **params) params = VitableConnect::Internal::Types::Utils.normalize_keys(params) request_data = VitableConnect::Enrollments::Types::ReissueEnrollmentRequest.new(params).to_h non_body_param_names = %w[enrollment_id X-Vitable-Organization] body = request_data.except(*non_body_param_names) headers = {} headers["X-Vitable-Organization"] = params[:vitable_organization] if params[:vitable_organization] request = VitableConnect::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v1/enrollments/#{URI.encode_uri_component(params[:enrollment_id].to_s)}/reissue", headers: headers, 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::ReissueEnrollmentResponse.load(response.body) else error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#terminate(request_options: {}, **params) ⇒ untyped
Terminates enrolled coverage immediately. An accepted qualifying life event owned by the enrollment member is required unless the plan is VPC or ICHRA. User-backed callers must provide a reason; it is optional for organization API-key callers. API keys may act across the caller organization's book. Tenant mismatches return the same non-disclosing 404 before the request body is validated.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/VitableConnect/enrollments/client.rb', line 137 def terminate(request_options: {}, **params) params = VitableConnect::Internal::Types::Utils.normalize_keys(params) request_data = VitableConnect::Enrollments::Types::TerminateEnrollmentRequest.new(params).to_h non_body_param_names = %w[enrollment_id X-Vitable-Organization] body = request_data.except(*non_body_param_names) headers = {} headers["X-Vitable-Organization"] = params[:vitable_organization] if params[:vitable_organization] request = VitableConnect::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v1/enrollments/#{URI.encode_uri_component(params[:enrollment_id].to_s)}/terminate", headers: headers, body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise VitableConnect::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = VitableConnect::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |