Categorygithub.com/impfbruecke/backend-go
modulepackage
0.0.0-20230307101734-0a9554e88fb9
Repository: https://github.com/impfbruecke/backend-go.git
Documentation: pkg.go.dev

# README

Impfbruecke

Go codecov GoDoc Go Report Card HitCount golangci-lint deepcode

Endpoints

GET /

Redirect to /call for convenience

Parameters:

none

GET /static

Serves static files like css and images from the /static directory. Place any file there you want make publicly avialable

Parameters:

none

GET /call

Show newCall.html page, which allows to create new calls

Parameters:

none

POST /call

Create a new call

Parameters:

TODO

GET /call/{id}

Information about call with ID {id}

Parameters:

none

GET /active

Show active.html, which displays active calls

Parameters:

none

GET /add

Show importPersons.html, which allows to add a single person to the database

Parameters:

none

POST /add

Add person to database

Parameters:

TODO

POST /upload

Upload .csv for bulk import of persons

Parameters:

TODO

POST /api/ja

Listen for incoming webhook to accept a appointment

Parameters:

TODO

POST /api/loeschen

Listen for incoming webhook to delete a single user from the database

Parameters:

TODO

POST /api/storno

Listen for incoming webhook to cancel an appointment

Parameters:

TODO

Twilio

Twilio Nummer: +49 xxx xxxxxxxx

Hab Twilio aufgesetzt:

Eingehende SMS werden folgt verarbeitet und triggern dann API Calls bei der Impfbruecke :

https://www.twilio.com/docs/studio/widget-library/http-request

SMS InhaltJASTORNOLOESCHEN LÖSCHEN
API Call/ja/storno/loeschen

Der endpunkt ist über Base Auth möglich also "https://user:[email protected]/api/ja" Die payload ist überall die gleiche und beinhaltet die Absendernummer im e.164 format

{
"from": "+49xxxxxxxxx"
}

Der Weg um SMS zu senden läuft auch über eine REST API

https://www.twilio.com/docs/studio/rest-api

Endpoint ist ein POST auf "https://studio.twilio.com/v2/Flows/Sid/Executions" mit den Parametern "To" und "From" und Parameters=json

folgende ausgehende SMS sind möglich:

NameAnfrageAbsageZusageLoeschbestaetigung
JSONABBB

folgende JSONs gibt es

A: Dieser JSON schicke ein Send&Wait.SMS inhalt in "message" packen und mit waitSeconds die Wartezeit definieren.


{
"type": "anfrage",
"message":"string",
"waitSeconds":3600
}

waitSeconds: definiert den Wert wie lange auf eine Antwort gewartet wird. Wenn 'waitTime > waitSeconds' wird ein STORNO ausgeführt. Wenn eine Antwort kommt, wird diese wieder geparsed und bei JA kommt eine Bestätigung.

Dieser JSON kann einfach nur stupide SMS verschicken. SMS inhalt in "message" packen und spaß haben B:

{
"type": "nachricht",
"message":"string"
}

# Functions

NewBridge creates a new instance of the bridge using predifined parameters from env vars, global vars and/or defaults.
NewCall creates a new call.
NewPerson receives the input data and returns a slice of person objects.
NewTwillioSender creates a new instance of the sender from the parameters passed.

# Structs

Bridge is the main struct of the application.
Call represents a call issued by a user.
CallStatus bundles a call and the persons who have accepted it for simpler rendering in the html templates.
ImpfUser is a row from the users table.
Person represents a person that has been imported to be notified for calls.
TmplData bundles the data that is passed to the html templates for easier and uniform acces to it.
TwillioSender abstracts interactions with the twilio API.
User holds a users account information.