Skip to content

Commit

Permalink
PP-11212 Small refactorings
Browse files Browse the repository at this point in the history
- Remove unused enum values
- Extract some types declared inline into interfaces
  • Loading branch information
stephencdaly committed Jan 11, 2024
1 parent f94a898 commit 6e16a49
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
2 changes: 0 additions & 2 deletions src/lib/providers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export const providers = {
sandbox: 'sandbox',
worldpay: 'worldpay',
smartpay: 'smartpay',
epdq: 'epdq',
stripe: 'stripe'
}
48 changes: 26 additions & 22 deletions src/web/modules/gateway_accounts/gateway_accounts.http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ async function listCSV(req: Request, res: Response): Promise<void> {
res.status(200).send(format(data))
}

interface CreateGatewayAccountPageData {
linkedCredentials: string;
live: string;
provider: string;
recovered?: object;
service?: Service;
description?: string;
flash: object;
errors?: ClientFormError[];
errorMap?: object;
csrf: string;
}

async function create(req: Request, res: Response): Promise<void> {
const serviceId = req.query.service as string
const live = req.query.live as string
Expand All @@ -81,18 +94,7 @@ async function create(req: Request, res: Response): Promise<void> {
throw new Error('Expected "live" and "provider" query parameters')
}

const context: {
linkedCredentials: string;
live: string;
provider: string;
recovered?: object;
service?: Service;
description?: string;
flash: object;
errors?: ClientFormError[];
errorMap?: object;
csrf: string;
} = {
const context: CreateGatewayAccountPageData = {
linkedCredentials: req.query.credentials as string,
live,
provider,
Expand Down Expand Up @@ -630,6 +632,17 @@ async function searchRequest(req: Request, res: Response, next: NextFunction): P
}
}

interface AgentInitiatedMotoPageData {
account: GatewayAccount;
service: Service;
products: Product[];
csrf: string;
formValues?: object;
flash: object;
errors?: object;
errorMap?: object[];
}

async function agentInitiatedMotoPage(
req: Request,
res: Response
Expand All @@ -642,16 +655,7 @@ async function agentInitiatedMotoPage(
Products.accounts.listProductsByType(id, ProductType.Moto)
])

const context: {
account: GatewayAccount;
service: Service;
products: Product[];
csrf: string;
formValues?: object;
flash: object;
errors?: object;
errorMap?: object[];
} = {
const context: AgentInitiatedMotoPageData = {
account: account,
service: service,
products: products,
Expand Down

0 comments on commit 6e16a49

Please sign in to comment.