Skip to content

Commit

Permalink
Some initial refactor and draft code
Browse files Browse the repository at this point in the history
Add code framework for endpoints

Get endpoint implementation done

WIP implement post endpoint
  • Loading branch information
diderikvw committed Oct 24, 2024
1 parent fd63ca7 commit 0547670
Show file tree
Hide file tree
Showing 22 changed files with 219 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '@121-service/src/payments/fsp-integration/intersolve-visa/entities/intersolve-visa-wallet.entity';
import { IntersolveBlockTokenReasonCodeEnum } from '@121-service/src/payments/fsp-integration/intersolve-visa/enums/intersolve-block-token-reason-code.enum';
import { IntersolveVisaTokenStatus } from '@121-service/src/payments/fsp-integration/intersolve-visa/enums/intersolve-visa-token-status.enum';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configuration.entity';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/entities/program-financial-service-provider-configuration.entity';
import { CustomHttpService } from '@121-service/src/shared/services/custom-http.service';
import { FileImportService } from '@121-service/src/utils/file-import/file-import.service';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { PaymentProcessorCommercialBankEthiopia } from '@121-service/src/payment
import { RedisModule } from '@121-service/src/payments/redis/redis.module';
import { TransactionEntity } from '@121-service/src/payments/transactions/transaction.entity';
import { TransactionsModule } from '@121-service/src/payments/transactions/transactions.module';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configuration.entity';
import { ProgramFinancialServiceProviderConfigurationRepository } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configurations.repository';
import { ProgramEntity } from '@121-service/src/programs/program.entity';
import { RegistrationEntity } from '@121-service/src/registration/registration.entity';
Expand All @@ -21,6 +20,7 @@ import { CustomHttpService } from '@121-service/src/shared/services/custom-http.
import { UserModule } from '@121-service/src/user/user.module';
import { createScopedRepositoryProvider } from '@121-service/src/utils/scope/createScopedRepositoryProvider.helper';
import { SoapService } from '@121-service/src/utils/soap/soap.service';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/entities/program-financial-service-provider-configuration.entity';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ImageCodeModule } from '@121-service/src/payments/imagecode/image-code.
import { RedisModule } from '@121-service/src/payments/redis/redis.module';
import { TransactionEntity } from '@121-service/src/payments/transactions/transaction.entity';
import { TransactionsModule } from '@121-service/src/payments/transactions/transactions.module';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configuration.entity';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/entities/program-financial-service-provider-configuration.entity';
import { ProgramFinancialServiceProviderConfigurationRepository } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configurations.repository';
import { ProgramEntity } from '@121-service/src/programs/program.entity';
import { ProgramAidworkerAssignmentEntity } from '@121-service/src/programs/program-aidworker.entity';
Expand Down
2 changes: 1 addition & 1 deletion services/121-service/src/payments/payments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { TransactionStatusEnum } from '@121-service/src/payments/transactions/en
import { TransactionEntity } from '@121-service/src/payments/transactions/transaction.entity';
import { TransactionScopedRepository } from '@121-service/src/payments/transactions/transaction.repository';
import { TransactionsService } from '@121-service/src/payments/transactions/transactions.service';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configuration.entity';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/entities/program-financial-service-provider-configuration.entity';
import { ProgramFinancialServiceProviderConfigurationRepository } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configurations.repository';
import { ProgramEntity } from '@121-service/src/programs/program.entity';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {

import { Base121AuditedEntity } from '@121-service/src/base-audited.entity';
import { LatestTransactionEntity } from '@121-service/src/payments/transactions/latest-transaction.entity';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configuration.entity';
import { ProgramEntity } from '@121-service/src/programs/program.entity';
import { RegistrationEntity } from '@121-service/src/registration/registration.entity';
import { UserEntity } from '@121-service/src/user/user.entity';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/entities/program-financial-service-provider-configuration.entity';

@Entity('transaction')
export class TransactionEntity extends Base121AuditedEntity {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {

Check failure on line 1 in services/121-service/src/program-financial-service-provider-configurations/dtos/create-program-financial-service-provider-configuration.dto.ts

View workflow job for this annotation

GitHub Actions / test

Run autofix to sort these imports!
FinancialServiceProviderConfigurationEnum,

Check failure on line 2 in services/121-service/src/program-financial-service-provider-configurations/dtos/create-program-financial-service-provider-configuration.dto.ts

View workflow job for this annotation

GitHub Actions / test

'FinancialServiceProviderConfigurationEnum' is defined but never used. Allowed unused vars must match /^_/u
FinancialServiceProviderName,
} from '@121-service/src/financial-service-providers/enum/financial-service-provider-name.enum';
import { LocalizedString } from '@121-service/src/shared/types/localized-string.type';
import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString } from 'class-validator';

export class CreateProgramFinancialServiceProviderConfigurationDto {
// TODO: Do we accept spaces in the name? Any other naming criteria? Special characters? All lowercase?
@ApiProperty({ example: 'VisaDebitCards' })
@IsNotEmpty()
@IsString()
public readonly name: string;

@ApiProperty({
example: {
en: 'Visa Debit Cards',
nl: 'Visa-betaalkaarten',
},
})
@IsNotEmpty()
public readonly label: LocalizedString;

@ApiProperty({
enum: FinancialServiceProviderName,
type: 'enum',
example: FinancialServiceProviderName.intersolveVoucherWhatsapp,
})
@IsNotEmpty()
public readonly financialServiceProviderName: FinancialServiceProviderName;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import { LocalizedString } from '@121-service/src/shared/types/localized-string.

export class ProgramFinancialServiceProviderConfigurationResponseDto {
@ApiProperty({ example: 1, type: 'number' })
public programId: number;
public readonly programId: number;

@ApiProperty({ enum: FinancialServiceProviders, type: 'enum' })
public financialServiceProviderName: FinancialServiceProviders;

@ApiProperty({ example: 'FSP Name', type: 'string' })
public name: string;
public readonly name: string;

@ApiProperty({ type: 'object' })
public label: LocalizedString;
public readonly label: LocalizedString;

@ApiProperty({ type: 'object' })
public financialServiceProvider: FinancialServiceProviderDto;
public readonly financialServiceProvider: FinancialServiceProviderDto;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CascadeDeleteEntity } from '@121-service/src/base.entity';

Check failure on line 1 in services/121-service/src/program-financial-service-provider-configurations/entities/program-financial-service-provider-configuration-property.entity.ts

View workflow job for this annotation

GitHub Actions / test

Run autofix to sort these imports!
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/entities/program-financial-service-provider-configuration.entity';
import { isObject } from 'lodash';
import {
Column,
Expand All @@ -8,9 +10,6 @@ import {
Unique,
} from 'typeorm';

import { CascadeDeleteEntity } from '@121-service/src/base.entity';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configuration.entity';

@Unique('programFinancialServiceProviderConfigurationPropertyUnique', [
'programFinancialServiceProviderConfigurationId',
'name',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { CascadeDeleteEntity } from '@121-service/src/base.entity';

Check failure on line 1 in services/121-service/src/program-financial-service-provider-configurations/entities/program-financial-service-provider-configuration.entity.ts

View workflow job for this annotation

GitHub Actions / test

Run autofix to sort these imports!
import { TransactionEntity } from '@121-service/src/payments/transactions/transaction.entity';
import { ProgramFinancialServiceProviderConfigurationPropertyEntity } from '@121-service/src/program-financial-service-provider-configurations/entities/program-financial-service-provider-configuration-property.entity';
import { ProgramEntity } from '@121-service/src/programs/program.entity';
import { LocalizedString } from '@121-service/src/shared/types/localized-string.type';
import {
Column,
Entity,
Expand All @@ -8,13 +13,7 @@ import {
Unique,
} from 'typeorm';

import { CascadeDeleteEntity } from '@121-service/src/base.entity';
import { ProgramEntity } from '@121-service/src/programs/program.entity';
import { FinancialServiceProviders } from '@121-service/src/financial-service-providers/enum/financial-service-provider-name.enum';
import { TransactionEntity } from '@121-service/src/payments/transactions/transaction.entity';
import { ProgramFinancialServiceProviderConfigurationPropertyEntity } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configuration-property.entity';

import { LocalizedString } from '@121-service/src/shared/types/localized-string.type';

@Unique('programFinancialServiceProviderConfigurationUnique', [
'programId',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FINANCIAL_SERVICE_PROVIDERS } from '@121-service/src/financial-service-providers/financial-service-providers.const';
import { ProgramFinancialServiceProviderConfigurationResponseDto } from '@121-service/src/program-financial-service-provider-configurations/dtos/program-financial-service-provider-configuration-response.dto';
import { ProgramFinancialServiceProviderConfigurationEntity } from '@121-service/src/program-financial-service-provider-configurations/program-financial-service-provider-configuration.entity';
import { ProgramFinancialServiceProviderConfigurationEntity } from '../entities/program-financial-service-provider-configuration.entity';

Check warning on line 3 in services/121-service/src/program-financial-service-provider-configurations/mappers/program-financial-service-provider-configuration.mapper.ts

View workflow job for this annotation

GitHub Actions / test

import statements should have an absolute path

export class ProgramFinancialServiceProviderConfigurationMapper {
public static mapEntitiesToDtos(
Expand All @@ -14,12 +14,6 @@ export class ProgramFinancialServiceProviderConfigurationMapper {
public static mapEntitytoDto(
entity: ProgramFinancialServiceProviderConfigurationEntity,
): ProgramFinancialServiceProviderConfigurationResponseDto {
const dto = new ProgramFinancialServiceProviderConfigurationResponseDto();

dto.programId = entity.programId;
dto.financialServiceProviderName = entity.financialServiceProviderName;
dto.name = entity.name;
dto.label = entity.label;
const financialServiceProvider = FINANCIAL_SERVICE_PROVIDERS.find(
(fsp) => fsp.name === entity.financialServiceProviderName,
);
Expand All @@ -28,7 +22,14 @@ export class ProgramFinancialServiceProviderConfigurationMapper {
'Financial service provider assigned to program not found in the list of available financial service providers',
);
}
dto.financialServiceProvider = financialServiceProvider;

const dto: ProgramFinancialServiceProviderConfigurationResponseDto = {
programId: entity.programId,
financialServiceProviderName: entity.financialServiceProviderName,
name: entity.name,
label: entity.label,
financialServiceProvider: financialServiceProvider,
};
return dto;
}
}
Loading

0 comments on commit 0547670

Please sign in to comment.