bcgov / SIMS

Student Information Management System. Post-Secondary Student Financial Aid System
Apache License 2.0
24 stars 13 forks source link

CAS Integration 1 - Add CAS Supplier Info to Student Profile (Get Supplier Number) #3255

Closed HRAGANBC closed 2 months ago

HRAGANBC commented 4 months ago

User Story: SIMS must record and maintain a student's 'supplier' information as part of their profile, so that a student's SIMS profile can match with their corresponding account in the Corporate Accounting System (CAS), and SIMS can relay critical information about that student to CAS.

Acceptance Criteria:

Initiate 'Get Supplier' Process

Technical

Technical Context:

Question: Should the auth token be stored in Redis as we know how long the token is valid for?

Stephen or Jason to supply required connection information (.env)

Sample Code

  async authenticate(): Promise<any> {
    const url = `${this.baseUrl}/oauth/token`;
    const auth = Buffer.from(`${this.clientId}:${this.clientSecret}`).toString(
      'base64',
    );
    const headers = {
      'Content-Type': 'application/x-www-form-urlencoded',
      Authorization: `Basic ${auth}`,
    };
    const body = new URLSearchParams();
    body.append('grant_type', 'client_credentials');
    const config: AxiosRequestConfig = {
      headers,
    };
    const response = await firstValueFrom(
      this.httpService.post(url, body.toString(), config),
    );
    return response.data as AuthResult;
  }

  async getSupplier(token: string, sin: string, surname: string): Promise<any> {
    const url = `${this.baseUrl}/cfs/supplier/${surname}/lastname/${sin}/sin`;
    const headers = {
      Authorization: `Bearer ${token}`,
    };
    const config: AxiosRequestConfig = {
      headers,
    };
    const response = await firstValueFrom(this.httpService.get(url, config));
    return response.data as SupplierQueryResult;
  }

Mock-Ups

Fig 2 - Success Response Format for Get Supplier Number Process

image.png

Doc 1 Supplier Web Service RESTful Client Onboarding v02_01.pdf

Doc 2: Individual Supplier Web Service Field Requirements (All Requests) JAN2023.xlsx

sslaws commented 4 months ago

@HRAGANBC we should review this and then take it to grooming

guru-aot commented 2 months ago

@andrewsignori-aot

  1. the understanding on Upon student creation, create a new entry in the sims.cas_suppliers and have it associated with a new column in sims.students.cas_supplier_id table. This would follow the same idea from sims.sin_validations and sims.students.sin_validation_id., why are we creating an entry if the student is not validated for sin and on creation?
  2. On displaying the table cas_suppliers UI in the ministry portal, the line items for the suppliers for a particular student has to be fetched from this table cas_suppliers. Without the relation of student_id in the table how we could display muliple rows?
  3. Reason for having Pending address verification status in the enum.
  4. What will be the enum status if the CAS call is failure or no response is returned.
  5. When a manual Edit Info is added for a particular student only SupplierNumber and SiteCode information is populated? What other information has to be updated in the sims.cas_suppliers table other than the supplier_status as Verified manually?
  6. Efforts on configuration for cas api, like the URL endpoint, authentication parameters in our project is not captured. Do we need it initially as a first effort and from there create the table for cas_suppliers as subsequent efforts?
andrewsignori-aot commented 2 months ago

@andrewsignori-aot

  1. the understanding on Upon student creation, create a new entry in the sims.cas_suppliers and have it associated with a new column in sims.students.cas_supplier_id table. This would follow the same idea from sims.sin_validations and sims.students.sin_validation_id., why are we creating an entry if the student is not validated for sin and on creation?
  2. On displaying the table cas_suppliers UI in the ministry portal, the line items for the suppliers for a particular student has to be fetched from this table cas_suppliers. Without the relation of student_id in the table how we could display muliple rows?
  3. Reason for having Pending address verification status in the enum.
  4. What will be the enum status if the CAS call is failure or no response is returned.
  5. When a manual Edit Info is added for a particular student only SupplierNumber and SiteCode information is populated? What other information has to be updated in the sims.cas_suppliers table other than the supplier_status as Verified manually?
  6. Efforts on configuration for cas api, like the URL endpoint, authentication parameters in our project is not captured. Do we need it initially as a first effort and from there create the table for cas_suppliers as subsequent efforts?
  1. Following the same approach from SIN we ensure there will always be a status associated with the student even if it is "pending".
  2. Following the same approach from SIN we can have the student ID added.
  3. Pending address verification is reserved for future use when students update their profiles and we need to communicate CAS. It is not part of this ticket and it can be added later if the Team is not willing to have it added now.
  4. Failure to call CAS should keep the status as it is to a new attempt happen. 404 will be returned if not student was found and I believe that we can set the is_valid to false and set the record as validated.
  5. Details for manual editing will be clarified in upcoming tickets.
  6. The effort for the authentication is specified on "Create new secrets to store the Client ID and Client Secret." and we can just have the API URL added.
andrepestana-aot commented 2 months ago

@HRAGANBC @sslaws @JasonCTang

I have some questions I couldn't find in the documentation or ACs:

HRAGANBC commented 2 months ago

@andrepestana-aot

Can a supplier response have more that one "item"? If so, should we ignore the rest?

My understanding is that you can only have one item, but Nino has asked CAS for confirmation

Is it possible that a supplier does not have an address? What to do if so?

My understanding is that is not possible, but Nino has asked CAS for confirmation

What's criteria to set isValid to true for a supplier? Should it just set isValid to true if there's a response for the request?

My understanding is that is a variable we define ourselves to reflect whether or not SIMS has all the information it needs from CAS transactions. We set isValid = true when:

@ninosamson @sslaws FYI

ninosamson commented 2 months ago

Hi @andrepestana-aot.

Confirming that all suppliers MUST have an address as per minimum requirement on creation.

andrepestana-aot commented 2 months ago

@ninosamson Could you confirm if the lastname for the request should be all in upper case, please?. In my tests I had different results with upper and lower cases.

ninosamson commented 2 months ago

From the documentation @andrepestana-aot

image.png