registreerocks / registree-core

0 stars 0 forks source link

feat: add messaging module to wrap twilio api #411

Closed billguo99 closed 2 years ago

billguo99 commented 2 years ago

Resolves #406.

Steps done:

  1. yarn add twilio nestjs-twilio
  2. Use nestjs cli to generate module and service for messaging
  3. Add twilio.config.ts in config, to use AppConfigService to setup Twilio client in MessagingModule
  4. Use customdirector @InjectTwilio MESSGING_OPTIONS to inject creds into MessagingService Twilio client and create simple async sendSMS() function
billguo99 commented 2 years ago

Tested in GraphQL Playground 🎉 Mutation:

mutation{
  sendSMS(body: "Hi", to: "+27825893193")
}

Return:

{
  "data": {
    "sendSMS": "SM920c33ad3e8044fba8b1ff03e7f0ca90"
  }
}

ToDo:

codecov[bot] commented 2 years ago

Codecov Report

Merging #411 (09c0197) into staging (684f754) will decrease coverage by 0.32%. The diff coverage is 62.50%.

Impacted file tree graph

@@             Coverage Diff             @@
##           staging     #411      +/-   ##
===========================================
- Coverage    77.49%   77.17%   -0.33%     
===========================================
  Files          147      151       +4     
  Lines         2191     2239      +48     
  Branches       140      142       +2     
===========================================
+ Hits          1698     1728      +30     
- Misses         459      476      +17     
- Partials        34       35       +1     
Impacted Files Coverage Δ
src/query-data/query-data.service.ts 36.76% <0.00%> (-2.92%) :arrow_down:
src/messaging/messaging.service.ts 37.50% <37.50%> (ø)
src/queries/queries.service.ts 50.69% <40.00%> (-0.39%) :arrow_down:
src/app-config/app-config.module.ts 100.00% <100.00%> (ø)
src/app-config/app-config.service.ts 92.30% <100.00%> (+1.00%) :arrow_up:
src/app-config/config/twilio.config.ts 100.00% <100.00%> (ø)
src/app.module.ts 97.14% <100.00%> (+0.08%) :arrow_up:
src/messaging/messaging.constants.ts 100.00% <100.00%> (ø)
src/messaging/messaging.module.ts 100.00% <100.00%> (ø)
src/queries/dto/create-event-query.input.ts 96.55% <100.00%> (+0.12%) :arrow_up:
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 684f754...09c0197. Read the comment docs.

billguo99 commented 2 years ago

Working for list of numbers: Mutation:

mutation{
  sendBulkSMS(message: "Testing duo numbers", numbers: ["+27765588901","+27825893193"])
}

Return:

{
  "data": {
    "sendBulkSMS": "SMbbef6c02daf9407aab82c03bb35277d5,SM9731072d7dd34ccdb092156e9aed0ab4"
  }
}