-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(billing): updated billing fe/be to use dto
- Loading branch information
Showing
4 changed files
with
25 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,21 @@ | ||
import axios from 'axios' | ||
|
||
import { BillingInformationDto } from '../../types/api/billing' | ||
import { BillingInfoDto, BillingQueryDto } from '../../types/api/billing' | ||
|
||
// Exported for testing | ||
export const BILLING_ENDPOINT = '/billing' | ||
|
||
/** | ||
* Gets the billing information for the given month and year | ||
* @param yr The year to get the billing information for | ||
* @param mth The month to get the billing information for | ||
* @param esrvcId The id of the form | ||
* @param billingQueryParams The formId and the specific month to get the information for | ||
* @returns Promise<BillingResult> The billing statistics of the given month | ||
*/ | ||
export const getBillingInfo = ( | ||
yr: string, | ||
mth: string, | ||
esrvcId: string, | ||
): Promise<BillingInformationDto> => { | ||
billingQueryParams: BillingQueryDto, | ||
): Promise<BillingInfoDto> => { | ||
return axios | ||
.get<BillingInformationDto>(BILLING_ENDPOINT, { | ||
params: { | ||
yr, | ||
mth, | ||
esrvcId, | ||
}, | ||
.get<BillingInfoDto>(BILLING_ENDPOINT, { | ||
params: billingQueryParams, | ||
}) | ||
.then(({ data }) => data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
import { LoginStatistic } from '../../types' | ||
import { AuthType } from '../../types' | ||
|
||
// yr: The year to get the billing information for | ||
// mth: The month to get the billing information for | ||
// esrvcId: The id of the form | ||
export type BillingQueryDto = { | ||
esrvcId: string | ||
yr: string | ||
mth: string | ||
} | ||
|
||
export type BillingInformationDto = { loginStats: LoginStatistic[] } | ||
// NOTE: LoginStatistic is defined here and in src/types/login. | ||
// This is to allow the communication layer (the dto) to be agnostic of intermediate representations. | ||
type LoginStatistic = { | ||
adminEmail: string | ||
formName: string | ||
total: number | ||
formId: string | ||
authType: AuthType | ||
} | ||
|
||
export type BillingInfoDto = { loginStats: LoginStatistic[] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './core' | ||
export * from './form' | ||
export * from './billing' | ||
export * from './examples' |