diff --git a/modules/check_in/app/services/v2/chip/client.rb b/modules/check_in/app/services/v2/chip/client.rb index 495f7d29aba..6cfd0f2f148 100644 --- a/modules/check_in/app/services/v2/chip/client.rb +++ b/modules/check_in/app/services/v2/chip/client.rb @@ -152,6 +152,17 @@ def refresh_precheckin(token:) raise e end + ## + # HTTP POST call to the CHIP API to initiate check-in + # + # @return [Faraday::Response] + # + def initiate_check_in(token:) + connection.post("/#{base_path}/actions/initiate-check-in/#{check_in_session.uuid}") do |req| + req.headers = default_headers.merge('Authorization' => "Bearer #{token}") + end + end + ## # HTTP DELETE call to the CHIP API to delete check-in/pre check-in data # diff --git a/modules/check_in/spec/services/v2/chip/client_spec.rb b/modules/check_in/spec/services/v2/chip/client_spec.rb index b41281ebe4f..d925b793d52 100644 --- a/modules/check_in/spec/services/v2/chip/client_spec.rb +++ b/modules/check_in/spec/services/v2/chip/client_spec.rb @@ -249,6 +249,31 @@ end end + describe '#initiate_check_in' do + let(:resp) { Faraday::Response.new(body: { 'uuid' => uuid }.to_json, status: 200) } + let(:token) { 'abc123' } + + context 'when CHIP returns success' do + let(:resp) { Faraday::Response.new(body: { 'uuid' => uuid }.to_json, status: 200) } + let(:token) { 'abc123' } + + before do + allow_any_instance_of(Faraday::Connection).to receive(:post).with(anything).and_return(resp) + end + + it 'yields to block' do + expect_any_instance_of(Faraday::Connection).to receive(:post).with("/dev/actions/initiate-check-in/#{uuid}") + .and_yield(Faraday::Request.new) + + subject.initiate_check_in(token: token) + end + + it 'returns success response' do + expect(subject.initiate_check_in(token: token)).to eq(resp) + end + end + end + describe '#delete' do context 'when CHIP returns successfully' do let(:response) { Faraday::Response.new(body: 'Delete successful', status: 200) }