Skip to content

Commit

Permalink
feat: Expose QBD Direct Integration (#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 authored Oct 29, 2024
1 parent a4f9fa9 commit a81b687
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
FYLE_APP_URL: "http://lolo.fyle.tech"
SI_API_URL: "http://lolo.fyle.tech"
SAGE300_API_URL: "http://lolo.fyle.tech"
QBD_DIRECT_API_URL": "http://lolo.fyle.tech"
- name: Unit Test Coverage
uses: fylein/comment-test-coverage@master
with:
Expand Down
1 change: 1 addition & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ do
sed -i $SED_EXTRA_ARGS "s?{{QBD_API_URL}}?${QBD_API_URL}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{SI_API_URL}}?${SI_API_URL}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{SAGE300_API_URL}}?${SAGE300_API_URL}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{QBD_DIRECT_API_URL}}?${QBD_DIRECT_API_URL}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{BUSINESS_CENTRAL_API_URL}}?${BUSINESS_CENTRAL_API_URL}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{QBO_API_URL}}?${QBO_API_URL}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{XERO_API_URL}}?${XERO_API_URL}?g" $f;
Expand Down
1 change: 1 addition & 0 deletions scripts/setup_env.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const environment = {
qbd_api_url: `${process.env.QBD_API_URL ? process.env.QBD_API_URL : '{{QBD_API_URL}}'}`,
si_api_url: `${process.env.SI_API_URL ? process.env.SI_API_URL : '{{SI_API_URL}}'}`,
sage300_api_url: `${process.env.SAGE300_API_URL ? process.env.SAGE300_API_URL : '{{SAGE300_API_URL}}'}`,
qbd_direct_api_url: `${process.env.QBD_DIRECT_API_URL ? process.env.QBD_DIRECT_API_URL : '{{QBD_DIRECT_API_URL}}'}`,
netsuite_api_url: `${process.env.NETSUITE_API_URL ? process.env.NETSUITE_API_URL : '{{NETSUITE_API_URL}}'}`,
business_central_api_url: `${process.env.BUSINESS_CENTRAL_API_URL ? process.env.BUSINESS_CENTRAL_API_URL : '{{BUSINESS_CENTRAL_API_URL}}'}`,
qbo_api_url: `${process.env.QBO_API_URL ? process.env.QBO_API_URL : '{{QBO_API_URL}}'}`,
Expand Down
7 changes: 7 additions & 0 deletions src/app/auth/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { NetsuiteAuthService } from 'src/app/core/services/netsuite/netsuite-cor
import { XeroAuthService } from 'src/app/core/services/xero/xero-core/xero-auth.service';
import { exposeAppConfig } from 'src/app/branding/expose-app-config';
import { brandingConfig } from 'src/app/branding/branding-config';
import { QbdDirectAuthService } from 'src/app/core/services/qbd-direct/qbd-direct-core/qbd-direct-auth.service';

@Component({
selector: 'app-login',
Expand All @@ -37,6 +38,7 @@ export class LoginComponent implements OnInit {
private helperService: HelperService,
private qboAuthService: QboAuthService,
private qbdAuthService: QbdAuthService,
private qbdDirectAuthService: QbdDirectAuthService,
private route: ActivatedRoute,
private router: Router,
private sage300AuthService: Sage300AuthService,
Expand Down Expand Up @@ -77,6 +79,11 @@ export class LoginComponent implements OnInit {
this.qbdAuthService.qbdLogin(clusterDomainWithToken.tokens.refresh_token).subscribe();
}

if (this.exposeApps?.QBD_DIRECT) {
this.helperService.setBaseApiURL(AppUrl.QBD_DIRECT);
this.qbdDirectAuthService.login(clusterDomainWithToken.tokens.refresh_token).subscribe();
}

if (this.exposeApps?.SAGE300) {
this.helperService.setBaseApiURL(AppUrl.SAGE300);
this.sage300AuthService.loginWithRefreshToken(clusterDomainWithToken.tokens.refresh_token).subscribe();
Expand Down
15 changes: 10 additions & 5 deletions src/app/branding/expose-app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const exposeAppConfig: AllowedAppsConfiguration = {
XERO: true,
NETSUITE: true,
QBD: true,
BAMBOO: true
BAMBOO: true,
QBD_DIRECT: true
},
'production-1-in': {
INTACCT: true,
Expand All @@ -22,7 +23,8 @@ export const exposeAppConfig: AllowedAppsConfiguration = {
XERO: true,
NETSUITE: true,
QBD: true,
BAMBOO: true
BAMBOO: true,
QBD_DIRECT: false
},
'production-1-us': {
INTACCT: true,
Expand All @@ -33,7 +35,8 @@ export const exposeAppConfig: AllowedAppsConfiguration = {
XERO: true,
NETSUITE: true,
QBD: true,
BAMBOO: true
BAMBOO: true,
QBD_DIRECT: false
}
},
co: {
Expand All @@ -46,7 +49,8 @@ export const exposeAppConfig: AllowedAppsConfiguration = {
XERO: true,
NETSUITE: true,
QBD: false,
BAMBOO: false
BAMBOO: false,
QBD_DIRECT: false
},
'c1-production-1-us': {
INTACCT: true,
Expand All @@ -57,7 +61,8 @@ export const exposeAppConfig: AllowedAppsConfiguration = {
XERO: true,
NETSUITE: true,
QBD: false,
BAMBOO: false
BAMBOO: false,
QBD_DIRECT: false
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type AllowedAppsConfiguration = {
NETSUITE: boolean;
QBD: boolean;
BAMBOO: boolean;
QBD_DIRECT: boolean;
}
}
};
2 changes: 1 addition & 1 deletion src/app/core/services/common/helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class HelperService {
const apiUrlMap: AppUrlMap = {
[AppUrl.INTACCT]: environment.production ? `${this.apiBaseUrl}/intacct-api/api` : environment.si_api_url,
[AppUrl.QBD]: environment.qbd_api_url,
[AppUrl.QBD_DIRECT]: ('qbd_direct_api_url' in environment) ? environment.qbd_direct_api_url as string : "",
[AppUrl.QBD_DIRECT]: environment.qbd_direct_api_url,
[AppUrl.TRAVELPERK]: `${this.apiBaseUrl}/${environment.production ? 'integrations-api/': ''}api`,
[AppUrl.BAMBOO_HR]: `${this.apiBaseUrl}/${environment.production ? 'integrations-api/': ''}api`,
[AppUrl.SAGE300]: environment.sage300_api_url,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Token } from 'src/app/core/models/misc/token.model';
import { ApiService } from '../../common/api.service';

@Injectable({
providedIn: 'root'
})
export class QbdDirectAuthService {

constructor() { }
constructor(
private apiService: ApiService
) { }

login(refresh_token: string): Observable<Token> {
return this.apiService.post('/auth/login_with_refresh_token/', { refresh_token: refresh_token });
}
}

0 comments on commit a81b687

Please sign in to comment.