-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9786354
commit cc09272
Showing
10 changed files
with
165 additions
and
13 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
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
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
28 changes: 28 additions & 0 deletions
28
libs/backend-ddd/src/opportunity/infrastructure/api/brevo/mock/brevoDeal.ts
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Maybe, Result } from 'true-myth' | ||
import { OpportunityRepository } from '../../../../domain/spi' | ||
import { OpportunityDetailsShort, OpportunityId } from '../../../../domain/types' | ||
|
||
// "Opportunities" are called "Deals" in Brevo | ||
|
||
const addBrevoDeal: OpportunityRepository['create'] = async (): Promise<Result<OpportunityId, Error>> => { | ||
return Result.ok({ id: '0' } as OpportunityId) | ||
} | ||
|
||
const updateBrevoDeal: OpportunityRepository['update'] = async (): Promise<Maybe<Error | null>> => { | ||
return Maybe.of(null) | ||
} | ||
|
||
const getBrevoCreationDates = async (): Promise<Result<Date[], Error>> => { | ||
return Result.ok([] as Date[]) | ||
} | ||
|
||
const getDailyOpportunitiesByContactId = async (): Promise<Result<OpportunityDetailsShort[], Error>> => { | ||
return Result.ok([] as OpportunityDetailsShort[]) | ||
} | ||
|
||
export const brevoRepositoryTest: OpportunityRepository = { | ||
create: addBrevoDeal, | ||
update: updateBrevoDeal, | ||
readDates: getBrevoCreationDates, | ||
getDailyOpportunitiesByContactId: getDailyOpportunitiesByContactId | ||
} |
8 changes: 8 additions & 0 deletions
8
libs/backend-ddd/src/opportunity/infrastructure/api/brevo/mock/brevoMail.ts
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Maybe } from 'true-myth' | ||
import { MailerManager } from '../../../../domain/spi' | ||
|
||
export default class BrevoMailTest { | ||
sendReturnReceipt: MailerManager['sendReturnReceipt'] = async (): Promise<Maybe<Error> | void> => { | ||
console.log('send email') | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
libs/backend-ddd/src/opportunityHub/infrastructure/api/mock/bpiFrance.ts
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Maybe } from 'true-myth' | ||
import { AxiosInstance } from 'axios' | ||
import OpportunityHubAbstract from '../opportunityHubAbstract' | ||
import { Operators } from '@tee/data' | ||
|
||
export class BpiFranceTest extends OpportunityHubAbstract { | ||
protected _axios: AxiosInstance | ||
protected readonly _baseUrl = 'https://bpifrance.my.salesforce.com/services' | ||
protected readonly _operatorNames: Operators[] = ['Bpifrance'] | ||
|
||
constructor() { | ||
super() | ||
this._axios = { | ||
request: async () => { | ||
return { | ||
status: 200, | ||
data: {} | ||
} | ||
} | ||
} as unknown as AxiosInstance | ||
} | ||
|
||
public transmitOpportunity = async (): Promise<Maybe<Error>> => { | ||
return Maybe.nothing() | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
libs/backend-ddd/src/opportunityHub/infrastructure/api/mock/placeDesEntreprises.ts
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { Operators } from '@tee/data' | ||
import { Objective } from '@tee/common' | ||
import { Maybe } from 'true-myth' | ||
import { AxiosInstance } from 'axios' | ||
import Config from '../../../../config' | ||
import { Subject, subjectToIdMapping } from '../placedesentreprises/types' | ||
import OpportunityHubAbstract from '../opportunityHubAbstract' | ||
|
||
export class PlaceDesEntreprisesTest extends OpportunityHubAbstract { | ||
protected readonly _baseUrl = Config.PDE_API_BASEURL | ||
protected _axios: AxiosInstance | ||
protected readonly _operatorNames = [] // warning, invalid but never used since we override all possible external uses of this value right below | ||
constructor() { | ||
super() | ||
this._axios = { | ||
request: async () => { | ||
return { | ||
status: 200, | ||
data: {} | ||
} | ||
} | ||
} as unknown as AxiosInstance | ||
} | ||
|
||
override get operatorNames(): Operators[] | Error { | ||
return new Error('Operator List non valid for Place des entreprises') | ||
} | ||
|
||
override support = () => { | ||
return true | ||
} | ||
|
||
override shouldTransmit = async () => { | ||
return true | ||
} | ||
|
||
public transmitOpportunity = async (): Promise<Maybe<Error>> => { | ||
return Maybe.nothing() | ||
} | ||
|
||
async reachedDailyContactTransmissionLimit(): Promise<boolean> { | ||
return false | ||
} | ||
|
||
private _objectiveToPdeSubjectMapping: { [key in Objective]: Subject } = { | ||
[Objective.EnvironmentalImpact]: Subject.DemarcheEcologie, | ||
[Objective.EnergyPerformance]: Subject.Energie, | ||
[Objective.WaterConsumption]: Subject.Eau, | ||
[Objective.BuildingRenovation]: Subject.Energie, | ||
[Objective.SustainableMobility]: Subject.TransportMobilite, | ||
[Objective.WasteManagement]: Subject.Dechets, | ||
[Objective.EcoDesign]: Subject.DemarcheEcologie, | ||
[Objective.TrainOrRecruit]: Subject.BilanRSE, | ||
[Objective.MakeSavings]: Subject.DemarcheEcologie, | ||
[Objective.DurablyInvest]: Subject.DemarcheEcologie, | ||
[Objective.Biodiversity]: Subject.DemarcheEcologie, | ||
[Objective.UnknownYet]: Subject.DemarcheEcologie | ||
} | ||
|
||
subjectMapping(programObjectives: Objective[]): number { | ||
const defaultSubject = Subject.DemarcheEcologie | ||
if (programObjectives.length === 1) { | ||
const objective = programObjectives[0] | ||
const subjectKey = this._objectiveToPdeSubjectMapping[objective] | ||
return subjectToIdMapping[subjectKey] | ||
} else { | ||
return subjectToIdMapping[defaultSubject] | ||
} | ||
} | ||
} |