From 6675db4d6876ff7fa3461ede571db784df8a81d1 Mon Sep 17 00:00:00 2001 From: Srividhya Date: Wed, 24 Jan 2024 15:41:52 +0530 Subject: [PATCH] Add an endpoint to fetch user's ZAK token --- lib/zoom/actions/user.rb | 2 ++ spec/fixtures/user/zak.json | 3 +++ spec/lib/zoom/actions/user/zak_spec.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 spec/fixtures/user/zak.json create mode 100644 spec/lib/zoom/actions/user/zak_spec.rb diff --git a/lib/zoom/actions/user.rb b/lib/zoom/actions/user.rb index da28ee8b..1cd7c2d8 100644 --- a/lib/zoom/actions/user.rb +++ b/lib/zoom/actions/user.rb @@ -69,6 +69,8 @@ module User patch 'user_status_update', '/users/:id/status', permit: :status + + get 'user_zak', '/users/me/zak' end end end diff --git a/spec/fixtures/user/zak.json b/spec/fixtures/user/zak.json new file mode 100644 index 00000000..2971029b --- /dev/null +++ b/spec/fixtures/user/zak.json @@ -0,0 +1,3 @@ +{ + "token": "eyJ0eXAiOiJKV1QiLCJzdiI6IjAwMDAwMSIsInptX3NrbSI6InptX28ybSIsImFsZyI6IkhTMjU2In0.eyJhdWQiOiJjb" +} diff --git a/spec/lib/zoom/actions/user/zak_spec.rb b/spec/lib/zoom/actions/user/zak_spec.rb new file mode 100644 index 00000000..4e73ed63 --- /dev/null +++ b/spec/lib/zoom/actions/user/zak_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Zoom::Actions::User do + let(:zc) { zoom_client } + + describe '#user_zak action' do + context 'with a valid response' do + before :each do + stub_request( + :get, + zoom_url("/users/me/zak") + ).to_return(status: 200, + body: json_response('user', 'zak'), + headers: { 'Content-Type' => 'application/json' }) + end + + it 'returns a users zak token' do + res = zc.user_zak + expected_response = JSON.parse(json_response('user', 'zak')) + expect(res['token']).to eq(expected_response['token']) + end + end + end +end