Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor constructor parameters to use a TypeScript interface for TMpesaPay #62

Merged
merged 1 commit into from
Aug 8, 2023

Conversation

OdidaProtas
Copy link
Contributor

Refactor constructor parameters to use a TypeScript interface for TMpesaPay

This commit refactors the constructor of the TMpesaPay class to use a TypeScript interface, providing a more concise and organized way to handle the class's properties. Instead of individual parameters, the constructor now takes a single object of type TMpesaPay. This change improves readability and maintainability of the code.

Refactor constructor parameters to use a TypeScript interface for TMpesaPay

The constructor of the TMpesaPay class has been refactored to use a TypeScript interface, providing a more concise and organized approach to handle the class's properties. The changes include converting individual parameters to a single object of type TMpesaPay. This modification enhances code readability and maintainability, making it easier to manage properties and their defaults.

Before:

constructor(
  consumerKey: string,
  consumerSecret: string,
  businessShortCode: string,
  passkey: string,
  accountReference: string,
  transactionDesc: string,
  partyA: string,
  b2cSecurityCredential: string,
  initiatorName: string,
  environment: 'sandbox' | 'live' = 'sandbox',
  transactionType: 'paybill' | 'till' = 'paybill',
)

After

constructor({
  consumerKey,
  consumerSecret,
  businessShortCode,
  passkey,
  accountReference,
  transactionDesc,
  partyA,
  b2cSecurityCredential,
  initiatorName,
  environment,
  transactionType,
}: TMpesaPay)

By utilizing an interface, this change improves the overall structure and maintainability of the code, making it easier to extend and manage the class properties in the future.

@justinelut
Copy link
Owner

@all-contributors please add @OdidaProtas for Typescript Interface and code refactoring

@allcontributors
Copy link
Contributor

@justinelut

I've put up a pull request to add @OdidaProtas! 🎉

@justinelut justinelut merged commit bb76ca2 into justinelut:master Aug 8, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants