import { Base } from './base'; export class CustomerSsoService extends Base { private membershipApi = this.config.get('membershipApi'); private customerSsoApiKey = this.config.get('customerSsoApiKey'); /** * Updates a ft.com user profile with the given SAML user ID * @param userId The ID of the user's ft.com profile to update * @param sbidNumber(sbid_number in payload) The user's Student Beans ID */ public async linkUserAndStudentBeans(userId: string, sbidNumber: string): Promise { await this.requestPost({ url: `${this.membershipApi}/sso/students/${userId}`, key: this.customerSsoApiKey, body: { sbid_number: sbidNumber }, targetApiSystemCode: 'customer-sso', expectEmptyResponse: true }); return true; } /** * Updates a ft.com user profile with the given SAML user ID * @param userId The ID of the user's ft.com profile to update * @param samlUserId The user's SAML ID * @param email The user's email needs to be sent, if they're SSO-by-email setup */ public async updateUserData(userId: string, samlUserId: string, email: string): Promise { await this.requestPost({ url: `${this.membershipApi}/sso/ssoUserData/${userId}`, key: this.customerSsoApiKey, body: { samlUserId, ...(email ? { email } : null) }, targetApiSystemCode: 'customer-sso', expectEmptyResponse: true }); return true; } }