<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kajadhav</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kajadhav"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Kajadhav"/>
	<updated>2026-08-22T04:37:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149854</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149854"/>
		<updated>2023-04-22T22:15:24Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
'''Video:''' https://www.youtube.com/watch?v=pH1opJ1cArc&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kajadhav.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Pending_Request pending_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Processed_Request processed_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Pending Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Processed Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all previously approved or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Rejcted&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Rspp4.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://www.youtube.com/watch?v=pH1opJ1cArc&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149758</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149758"/>
		<updated>2023-04-15T09:55:01Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kajadhav.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Pending_Request pending_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Processed_Request processed_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Pending Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Processed Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all previously approved or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Rejcted&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Rspp4.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149757</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149757"/>
		<updated>2023-04-15T09:54:50Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kajadhav.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Pending_Request pending_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Processed_Request processed_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Pending Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Processed Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all previously approved or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Rejcted&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Rspp4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149756</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149756"/>
		<updated>2023-04-15T09:54:40Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kajadhav.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Pending_Request pending_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Processed_Request processed_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Pending Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Processed Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all previously approved or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Rejcted&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/&amp;lt;/code&amp;gt;&lt;br /&gt;
[[File:Rspp4.png|500px]]&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspp4.png&amp;diff=149755</id>
		<title>File:Rspp4.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Rspp4.png&amp;diff=149755"/>
		<updated>2023-04-15T09:54:18Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149754</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149754"/>
		<updated>2023-04-15T09:52:39Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* API documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kajadhav.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Pending_Request pending_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Processed_Request processed_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Pending Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Processed Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all previously approved or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Rejcted&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149753</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149753"/>
		<updated>2023-04-15T09:52:01Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* API documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kajadhav.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Pending%20Request pending_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Processed%20Request processed_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Pending Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Processed Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all previously approved or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Rejcted&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149752</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149752"/>
		<updated>2023-04-15T09:50:55Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* API documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kajadhav.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index pending_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index processed_request]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/processed_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Pending Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Processed Request ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all previously approved or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/pending_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Rejcted&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149751</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149751"/>
		<updated>2023-04-15T09:46:12Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Update */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kajadhav.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149750</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149750"/>
		<updated>2023-04-15T09:45:08Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Swagger UI screenshot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kajadhav.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Swagger_kajadhav.png&amp;diff=149749</id>
		<title>File:Swagger kajadhav.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Swagger_kajadhav.png&amp;diff=149749"/>
		<updated>2023-04-15T09:44:49Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149748</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149748"/>
		<updated>2023-04-15T09:43:38Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149747</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149747"/>
		<updated>2023-04-15T09:42:54Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Method: is_admin? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149746</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149746"/>
		<updated>2023-04-15T09:42:43Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Objectives */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149738</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149738"/>
		<updated>2023-04-14T01:27:14Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149737</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149737"/>
		<updated>2023-04-14T01:19:44Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request by user with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to Approve account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to Approve account request but user with same name already exists&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to Approve account request but user with same email already exists&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to Reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149736</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149736"/>
		<updated>2023-04-14T01:06:09Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request by user with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create an account request whose name or email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to accept account request&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149735</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149735"/>
		<updated>2023-04-14T01:04:50Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to list pending account requests&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to list processed account requests&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic false and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create an account request whose name or email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to accept account request&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to reject account request&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to check invalid status in PATCH /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to check invalid status in PUT /account_requests/:id&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to retrieve a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to delete a specific account request with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to delete a specific account request with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149651</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149651"/>
		<updated>2023-04-13T01:15:52Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* API documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE:''' '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs. Refer testing video below for more insights.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic false and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to check index with historic true and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to check index with historic true and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to create a new account request by user with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to create a new account request by admin with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to create an account request whose name or email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to update account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 25 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Test to check user creation and login&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Test to check user retrival&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149648</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149648"/>
		<updated>2023-04-13T01:14:46Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* API documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
Note that '''ALL''' APIs other than POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt; are auth protected. So, on swagger you will first need to sign up as an Administrator using POST &amp;lt;code&amp;gt;/users&amp;lt;/code&amp;gt; API before running such auth protected APIs.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic false and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to check index with historic true and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to check index with historic true and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to create a new account request by user with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to create a new account request by admin with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to create an account request whose name or email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to update account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 25 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Test to check user creation and login&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Test to check user retrival&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149638</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149638"/>
		<updated>2023-04-13T00:57:42Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Testing Video */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic false and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to check index with historic true and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to check index with historic true and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to create a new account request by user with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to create a new account request by admin with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to create an account request whose name or email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to update account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 25 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Test to check user creation and login&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Test to check user retrival&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
https://drive.google.com/file/d/19iSwZKnEXSDk45Q45rsLLYbJ66PDH_xo/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149616</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149616"/>
		<updated>2023-04-13T00:24:21Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Test Screenshot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic false and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to check index with historic true and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to check index with historic true and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to create a new account request by user with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to create a new account request by admin with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to create an account request whose name or email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to update account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 25 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Test to check user creation and login&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Test to check user retrival&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Testing Video ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149614</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149614"/>
		<updated>2023-04-13T00:23:57Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic false and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to check index with historic true and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to check index with historic true and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to create a new account request by user with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to create a new account request by admin with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to create an account request whose name or email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to update account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 25 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Test to check user creation and login&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Test to check user retrival&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Test to check insitituion index&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Test to check insitituion show&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Test to check insitituion create&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Test to check insitituion update&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Test to check insitituion delete&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149605</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149605"/>
		<updated>2023-04-13T00:21:46Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_requests_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/roles_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/users_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/institution_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic false and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and not signed in&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to check index with historic true and signed in with Administrator or Super Administrator.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to check index with historic true and signed in with any other role.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to create a new account request by user with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to create a new account request by admin with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to create a account request twice&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to create an account request whose name or email already exists in Users table&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to update account request with invalid or missing parameters&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 25 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149589</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149589"/>
		<updated>2023-04-13T00:05:11Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Delete */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Account Request deleted&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149586</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149586"/>
		<updated>2023-04-13T00:03:42Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Update */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @new_user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149585</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149585"/>
		<updated>2023-04-13T00:03:25Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Update */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject an Account Request or even Edit it. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH/PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 new intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Approved&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;msg&amp;quot;: &amp;quot;Account Request Approved and User successfully created.&amp;quot;,&lt;br /&gt;
  &amp;quot;user&amp;quot;: {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 25,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;email_on_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_submission&amp;quot;: false,&lt;br /&gt;
    &amp;quot;email_on_review_of_review&amp;quot;: false,&lt;br /&gt;
    &amp;quot;role&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;Student&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 19,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;stubbjb&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;institution&amp;quot;: {&lt;br /&gt;
      &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
      &amp;quot;name&amp;quot;: &amp;quot;North Carolina State University&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @user.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149582</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149582"/>
		<updated>2023-04-13T00:00:01Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Show */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149580</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149580"/>
		<updated>2023-04-12T23:58:20Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Show */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;uone1&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;uone1&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;uone1m@g.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Rejected&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:15:35.253Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:26:16.030Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149577</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149577"/>
		<updated>2023-04-12T23:56:51Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Index */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|False by default. If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149574</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149574"/>
		<updated>2023-04-12T23:55:59Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Create */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;id&amp;quot;: 3,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;userthree&amp;quot;,&lt;br /&gt;
  &amp;quot;fullname&amp;quot;: &amp;quot;User Three&amp;quot;,&lt;br /&gt;
  &amp;quot;email&amp;quot;: &amp;quot;u3@gmail.com&amp;quot;,&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
  &amp;quot;self_introduction&amp;quot;: &amp;quot;U3 intro&amp;quot;,&lt;br /&gt;
  &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T23:54:59.635Z&amp;quot;,&lt;br /&gt;
  &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_request.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149571</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149571"/>
		<updated>2023-04-12T23:53:34Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Index */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Success&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
status: :ok&lt;br /&gt;
&lt;br /&gt;
Failure&lt;br /&gt;
{ &lt;br /&gt;
  error: @account_requests.errors&lt;br /&gt;
}&lt;br /&gt;
status: :unprocessable_entity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149570</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149570"/>
		<updated>2023-04-12T23:51:25Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Index */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 1,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149569</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149569"/>
		<updated>2023-04-12T23:51:07Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Index */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 5,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;userone&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User One&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u1@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;I'm an MCS student, request to add my Student account&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T19:04:34.769Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
    &amp;quot;id&amp;quot;: 4,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;usertwo&amp;quot;,&lt;br /&gt;
    &amp;quot;fullname&amp;quot;: &amp;quot;User Two&amp;quot;,&lt;br /&gt;
    &amp;quot;email&amp;quot;: &amp;quot;u2@gmail.com&amp;quot;,&lt;br /&gt;
    &amp;quot;status&amp;quot;: &amp;quot;Under Review&amp;quot;,&lt;br /&gt;
    &amp;quot;self_introduction&amp;quot;: &amp;quot;U2's intro&amp;quot;,&lt;br /&gt;
    &amp;quot;created_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;updated_at&amp;quot;: &amp;quot;2023-04-12T16:21:28.549Z&amp;quot;,&lt;br /&gt;
    &amp;quot;role_id&amp;quot;: 2,&lt;br /&gt;
    &amp;quot;institution_id&amp;quot;: 1&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149568</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149568"/>
		<updated>2023-04-12T23:47:58Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* API documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
VCL Swagger URL: http://152.7.178.99:3000/api-docs/&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149567</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149567"/>
		<updated>2023-04-12T23:46:54Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* API documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
==== Swagger UI screenshot ====&lt;br /&gt;
[[File:Swagger kj p4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Swagger_kj_p4.png&amp;diff=149566</id>
		<title>File:Swagger kj p4.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Swagger_kj_p4.png&amp;diff=149566"/>
		<updated>2023-04-12T23:45:51Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149564</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149564"/>
		<updated>2023-04-12T23:43:31Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* API documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|delete a specific account request&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149562</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149562"/>
		<updated>2023-04-12T23:42:52Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Method: notify_supers_new_request */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: create_approved_user ====&lt;br /&gt;
If the Account Request is Approved, create a new user if all fields are valid and return it. If any invalid fields present, return error containing it's message.&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149561</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149561"/>
		<updated>2023-04-12T23:41:57Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Method: requested_user_params */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: notify_supers_new_request ====&lt;br /&gt;
Notifies all the super admins by email that request for a new account has been created&lt;br /&gt;
&lt;br /&gt;
==== Method: account_request_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149560</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149560"/>
		<updated>2023-04-12T23:41:22Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Method: foreign */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: is_admin? ====&lt;br /&gt;
Validate if the currently logged in user is an admin. Throw error if not admin. Login and auth is managed via POST /users on Swagger&lt;br /&gt;
&lt;br /&gt;
==== Method: notify_supers_new_request ====&lt;br /&gt;
Notifies all the super admins by email that request for a new account has been created&lt;br /&gt;
&lt;br /&gt;
==== Method: requested_user_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149559</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149559"/>
		<updated>2023-04-12T23:39:44Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Method: create */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user or admin to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: foreign ====&lt;br /&gt;
If the registered user status is Approved and if the new_user couldn't be saved, foreign function saves the role id in @all_roles variable&lt;br /&gt;
&lt;br /&gt;
==== Method: notify_supers_new_request ====&lt;br /&gt;
Notifies all the super admins by email that request for a new account has been created&lt;br /&gt;
&lt;br /&gt;
==== Method: requested_user_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149558</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149558"/>
		<updated>2023-04-12T23:39:32Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Method: index */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic, that is previously approved or rejected account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: foreign ====&lt;br /&gt;
If the registered user status is Approved and if the new_user couldn't be saved, foreign function saves the role id in @all_roles variable&lt;br /&gt;
&lt;br /&gt;
==== Method: notify_supers_new_request ====&lt;br /&gt;
Notifies all the super admins by email that request for a new account has been created&lt;br /&gt;
&lt;br /&gt;
==== Method: requested_user_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149550</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149550"/>
		<updated>2023-04-12T23:17:33Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/account_requests_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/institutions_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/api/v1/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/application.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;config/routes.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013301_create_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;db/migrate/20230412013310_add_keys_to_account_requests.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/models/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_requests_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/institution_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/roles_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/users_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;swagger/v1/swagger.yaml&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: foreign ====&lt;br /&gt;
If the registered user status is Approved and if the new_user couldn't be saved, foreign function saves the role id in @all_roles variable&lt;br /&gt;
&lt;br /&gt;
==== Method: notify_supers_new_request ====&lt;br /&gt;
Notifies all the super admins by email that request for a new account has been created&lt;br /&gt;
&lt;br /&gt;
==== Method: requested_user_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149544</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149544"/>
		<updated>2023-04-12T23:04:41Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Objectives */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending account requests, listing already approved or rejected requests, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like is_admin?, account_request_params, create_approved_user to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/account_request_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: foreign ====&lt;br /&gt;
If the registered user status is Approved and if the new_user couldn't be saved, foreign function saves the role id in @all_roles variable&lt;br /&gt;
&lt;br /&gt;
==== Method: notify_supers_new_request ====&lt;br /&gt;
Notifies all the super admins by email that request for a new account has been created&lt;br /&gt;
&lt;br /&gt;
==== Method: requested_user_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149543</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149543"/>
		<updated>2023-04-12T23:00:47Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Functionality */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending requested accounts, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like action_allowed?, foreign, notify_supers_new_request to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/account_request_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems. Check account_requests_controller and users_controller for better understanding.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: foreign ====&lt;br /&gt;
If the registered user status is Approved and if the new_user couldn't be saved, foreign function saves the role id in @all_roles variable&lt;br /&gt;
&lt;br /&gt;
==== Method: notify_supers_new_request ====&lt;br /&gt;
Notifies all the super admins by email that request for a new account has been created&lt;br /&gt;
&lt;br /&gt;
==== Method: requested_user_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149541</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149541"/>
		<updated>2023-04-12T22:59:18Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Objectives */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending requested accounts, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like action_allowed?, foreign, notify_supers_new_request to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
6. Implement simple Authorization for Swagger simply using session variables instead of complex code.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/account_request_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: foreign ====&lt;br /&gt;
If the registered user status is Approved and if the new_user couldn't be saved, foreign function saves the role id in @all_roles variable&lt;br /&gt;
&lt;br /&gt;
==== Method: notify_supers_new_request ====&lt;br /&gt;
Notifies all the super admins by email that request for a new account has been created&lt;br /&gt;
&lt;br /&gt;
==== Method: requested_user_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149540</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149540"/>
		<updated>2023-04-12T22:58:07Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Models */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending requested accounts, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like action_allowed?, foreign, notify_supers_new_request to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/account_request_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: foreign ====&lt;br /&gt;
If the registered user status is Approved and if the new_user couldn't be saved, foreign function saves the role id in @all_roles variable&lt;br /&gt;
&lt;br /&gt;
==== Method: notify_supers_new_request ====&lt;br /&gt;
Notifies all the super admins by email that request for a new account has been created&lt;br /&gt;
&lt;br /&gt;
==== Method: requested_user_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below. For more details, check UML diagram above:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149539</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149539"/>
		<updated>2023-04-12T22:57:01Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: /* Functionality */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending requested accounts, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like action_allowed?, foreign, notify_supers_new_request to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/account_request_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. For Authorization with swagger APIs, we use simply the session variable instead of using extra gems.&lt;br /&gt;
&lt;br /&gt;
8. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: foreign ====&lt;br /&gt;
If the registered user status is Approved and if the new_user couldn't be saved, foreign function saves the role id in @all_roles variable&lt;br /&gt;
&lt;br /&gt;
==== Method: notify_supers_new_request ====&lt;br /&gt;
Notifies all the super admins by email that request for a new account has been created&lt;br /&gt;
&lt;br /&gt;
==== Method: requested_user_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149538</id>
		<title>CSC/ECE 517 Spring 2023 - E2331. Reimplement Account Request module</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module&amp;diff=149538"/>
		<updated>2023-04-12T22:52:55Z</updated>

		<summary type="html">&lt;p&gt;Kajadhav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
In Expertiza, Account Creation can only be done by Admins and Super Admins. So, new users first request an account by clicking &amp;quot;Request Account&amp;quot; button on home page and filling out an account request form. After the user submits this form, the Admin or Super Admin is notified of the request and then he can decide to Accept or Reject such requests. If he accepts, then an email with new login details is sent to that user. &lt;br /&gt;
&lt;br /&gt;
The Account Request module is responsible for performing all these functions. In this project, we aim to write RESTful endpoints for the Account Request module CRUD operations along with adding the corresponding controllers and model files. We also add a few other non CRUD custom actions to the controller files which are required for the app to function normally. And, we also aim to write tests for the corresponding model and controller files.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
1. Write RESTful endpoints of create, show, index, update, destroy to simulate creating and approving new user accounts, listing pending requested accounts, creating a new account request, and notifying super-admins about new account requests. &lt;br /&gt;
&lt;br /&gt;
2. Add non CRUD custom actions like action_allowed?, foreign, notify_supers_new_request to support the above RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
3. Return proper status codes and proper validation for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
4. Write models and controllers such that they use modern approaches to writing Ruby code, including utilizing language features and adhering to best practices for object-oriented design.&lt;br /&gt;
&lt;br /&gt;
5. Write proper Rspec tests for all APIs, models, controllers.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
Kaushik Jadhav (unity_id: kajadhav, github: kaushikjadhav01)&lt;br /&gt;
&lt;br /&gt;
Aditi Vakeel (unity_id: avakeel, github: aditi-v79)&lt;br /&gt;
&lt;br /&gt;
Shivesh Madan Nath Jha (unity_id: sjha7, github: ShiveshJha12)&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
Ankur Mundra (unity_id: amundra, github: amundra)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
'''Github Repository:''' https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end &lt;br /&gt;
&lt;br /&gt;
'''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/29&lt;br /&gt;
&lt;br /&gt;
'''VCL Server:''' http://152.7.178.99:3000/&lt;br /&gt;
&lt;br /&gt;
'''VCL Swagger UI:''' http://152.7.178.99:3000/api-docs/&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/account_request_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/models/account_request.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;app/controllers/users_controller.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;spec/requests/api/v1/account_request_spec.rb&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
[[File:UML class kj p4.png|1000px]]&lt;br /&gt;
=== Functionality ===&lt;br /&gt;
In this project, we aim to add the following functions:&lt;br /&gt;
&lt;br /&gt;
1. Enable users to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
2. Enable admins to create a new Account Request.&lt;br /&gt;
&lt;br /&gt;
3. Enable admin to list pending requested accounts.&lt;br /&gt;
&lt;br /&gt;
4. Enable admins to Accept or Reject Account Requests.&lt;br /&gt;
&lt;br /&gt;
5. Enable admins to list previously accepted or rejected account requests.&lt;br /&gt;
&lt;br /&gt;
6. Ensure that data is validated properly in all the above APIs.&lt;br /&gt;
&lt;br /&gt;
7. Test cases for all the above.&lt;br /&gt;
&lt;br /&gt;
[[File:P4f1.png|900px]]&lt;br /&gt;
[[File:P4f2.png|900px]]&lt;br /&gt;
[[File:P4f3.png|900px]]&lt;br /&gt;
[[File:P4f5.png|900px]]&lt;br /&gt;
[[File:P4f6.png|900px]]&lt;br /&gt;
[[File:P4f4.png|900px]]&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
We create a new controller at &amp;lt;code&amp;gt;'''app/controllers/account_request_controller.rb'''&amp;lt;/code&amp;gt; with following methods:&lt;br /&gt;
&lt;br /&gt;
==== Method: index ====&lt;br /&gt;
This method gives a list of all pending account requests or historic account requests to Admin or Super Admin.&lt;br /&gt;
&lt;br /&gt;
==== Method: create ====&lt;br /&gt;
This method allows any user to create a new Account Request. On successful submission, admins are notified.&lt;br /&gt;
&lt;br /&gt;
==== Method: show ====&lt;br /&gt;
This method enables Admin or Super Admin to view a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: update ====&lt;br /&gt;
This method enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
==== Method: destroy ====&lt;br /&gt;
This method enables Admin or Super Admin to delete a specific Account Request&lt;br /&gt;
&lt;br /&gt;
==== Method: foreign ====&lt;br /&gt;
If the registered user status is Approved and if the new_user couldn't be saved, foreign function saves the role id in @all_roles variable&lt;br /&gt;
&lt;br /&gt;
==== Method: notify_supers_new_request ====&lt;br /&gt;
Notifies all the super admins by email that request for a new account has been created&lt;br /&gt;
&lt;br /&gt;
==== Method: requested_user_params ====&lt;br /&gt;
The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit. The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require. The permit method returns a copy of the parameters object, returning only the permitted keys and values. When creating a new ActiveRecord model, only the permitted attributes are passed into the model.&lt;br /&gt;
&lt;br /&gt;
=== Models ===&lt;br /&gt;
We create a new model &amp;lt;code&amp;gt;'''class AccountRequest'''&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;'''app/models/account_request.rb'''&amp;lt;/code&amp;gt; and add validations to all input fields as shown below:&lt;br /&gt;
&lt;br /&gt;
[[File:Model kj p4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
=== API documentation ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Method !! Endpoint !! Description &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Index index]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|returns a list of pending account requests or previously accepted or rejected account requests&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Create create]&lt;br /&gt;
|POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
|creates a new account request&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Show show]&lt;br /&gt;
|GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|retreive a specific account request&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Update update]&lt;br /&gt;
|PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|accept or reject an account request&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2023_-_E2331._Reimplement_Account_Request_module#Delete delete]&lt;br /&gt;
|DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
|deletes a participant from an assignment or a course&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Index ====&lt;br /&gt;
'''Description''': This endpoint gives a list of all pending account requests to Admin or Super Admin. A success response renders a JSON with all pending account requests.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Parameters''':&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Parameter !! Expected Value&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&amp;lt;code&amp;gt;historic&amp;lt;/code&amp;gt;&lt;br /&gt;
|true or false&lt;br /&gt;
|If true, returns a list historically accepted or rejected account requests. If false, returns pending account requests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create ====&lt;br /&gt;
'''Description''': This endpoint enables any user to create a new account request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': POST &amp;lt;code&amp;gt;/account_request&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Show ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to view a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': GET &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to Accept or Reject single or multiple Account Requests simultaneously. If accepted and if the account is not duplicate, the new account is generated for the user and the user is sent an email with the login credentials.&lt;br /&gt;
&lt;br /&gt;
'''Path''': PATCH &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Delete ====&lt;br /&gt;
'''Description''': This endpoint enables Admin or Super Admin to delete a specific Account Request.&lt;br /&gt;
&lt;br /&gt;
'''Path''': DELETE &amp;lt;code&amp;gt;/account_request/:id&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Request Body''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Work In Progress&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Design Pattern ==&lt;br /&gt;
A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.&lt;br /&gt;
&lt;br /&gt;
During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
The testing framework is RSpec. To test the RESTful APIs, we have used stubs and mocks. We have created some new models and added some associations in them which were required for stubbing.&lt;br /&gt;
&lt;br /&gt;
To run the tests:&lt;br /&gt;
&lt;br /&gt;
1. &amp;lt;code&amp;gt;git clone https://github.com/CSC-517-Spr23-kajadhav-avakeel-sjha7/reimplementation-back-end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. &amp;lt;code&amp;gt;cd reimplementation-back-end/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. &amp;lt;code&amp;gt;bundle install&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. &amp;lt;code&amp;gt;bundle exec rspec spec/requests/api/v1/account_request_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test ID !! Test Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Test to check index with historic false and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Test to check index with historic false and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Test to check index with historic true and valid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Test to check index with historic true and invalid parameters.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Test to create a new account request by user with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Test to create a new account request by admin with valid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Test to create a new account request by user with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Test to create a new account request by admin with invalid parameters&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Test to accept account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Test to reject account request by admin&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Test to accept account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Test to reject account request by user&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Test to retrieve a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Test to retrieve a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Test to retrieve a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test to retrieve a specific account request by admin with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Test to delete a specific account request by user with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Test to delete a specific account request by admin with valid id&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Test to delete a specific account request by user with invalid id&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Test to delete a specific account request by admin with invalid id&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Test Screenshot ====&lt;br /&gt;
Work in Progress&lt;br /&gt;
&lt;br /&gt;
==== Swagger UI Screenshot ====&lt;br /&gt;
Work in Progress&lt;/div&gt;</summary>
		<author><name>Kajadhav</name></author>
	</entry>
</feed>