Documentation ¶
Index ¶
- Constants
- func GenerateEmailFunc(code string) string
- func ValidateGenerateRetryOTPPayload(w http.ResponseWriter, r *http.Request) (*dto.GenerateRetryOTP, error)
- func ValidateSendEmailOTPPayload(w http.ResponseWriter, r *http.Request) (*dto.Email, error)
- func ValidateSendOTPPayload(w http.ResponseWriter, r *http.Request) (*dto.Msisdn, error)
- func ValidateVerifyOTPPayload(w http.ResponseWriter, r *http.Request, isEmail bool) (*dto.VerifyOTP, error)
- type ServiceOTP
- type ServiceOTPImpl
- func (s ServiceOTPImpl) EmailVerificationOtp(ctx context.Context, email *string) (string, error)
- func (s ServiceOTPImpl) GenerateAndSendOTP(ctx context.Context, msisdn string, appID *string) (string, error)
- func (s ServiceOTPImpl) GenerateOTP(ctx context.Context) (string, error)
- func (s ServiceOTPImpl) GenerateRetryOTP(ctx context.Context, msisdn *string, retryStep int, appID *string) (string, error)
- func (s ServiceOTPImpl) SaveOTPToFirestore(otp dto.OTP) error
- func (s ServiceOTPImpl) SendOTP(ctx context.Context, normalizedPhoneNumber string, code string, appID *string) (string, error)
- func (s ServiceOTPImpl) SendOTPToEmail(ctx context.Context, msisdn, email *string, appID *string) (string, error)
- func (s ServiceOTPImpl) SendTemporaryPIN(ctx context.Context, input dto.TemporaryPIN) error
- func (s ServiceOTPImpl) VerifyEmailOtp(ctx context.Context, email, verificationCode *string) (bool, error)
- func (s ServiceOTPImpl) VerifyOtp(ctx context.Context, msisdn, verificationCode *string) (bool, error)
Constants ¶
const ( //PINSMS is the sms formart to be send PINSMS = "" /* 144-byte string literal not displayed */ //PINWhatsApp is the whatsapp formart to be send PINWhatsApp = "" /* 142-byte string literal not displayed */ )
const ( ITCode = "123456" ITPhoneNumber = "0798000000" ITEmail = "test@healthcloud.co.ke" )
These constants are here to support Integration Testing done by the Frontend team. IT is shorthand for Integration Tests
const SendOtpToEmailTemplate = `` /* 17408-byte string literal not displayed */
SendOtpToEmailTemplate generates an email template
Variables ¶
This section is empty.
Functions ¶
func GenerateEmailFunc ¶
GenerateEmailFunc generates the custom email to be sent to the user when sending the OTP through email
func ValidateGenerateRetryOTPPayload ¶
func ValidateGenerateRetryOTPPayload(w http.ResponseWriter, r *http.Request) (*dto.GenerateRetryOTP, error)
ValidateGenerateRetryOTPPayload checks the validity of the request payload
func ValidateSendEmailOTPPayload ¶ added in v0.0.36
ValidateSendEmailOTPPayload checks the validity of the request payload
func ValidateSendOTPPayload ¶
ValidateSendOTPPayload checks the validity of the request payload
func ValidateVerifyOTPPayload ¶
func ValidateVerifyOTPPayload(w http.ResponseWriter, r *http.Request, isEmail bool) (*dto.VerifyOTP, error)
ValidateVerifyOTPPayload checks the validity of the request payload
Types ¶
type ServiceOTP ¶
type ServiceOTP interface { GenerateAndSendOTP(ctx context.Context, msisdn string, appID *string) (string, error) SendOTPToEmail(ctx context.Context, msisdn, email *string, appID *string) (string, error) SaveOTPToFirestore(otp dto.OTP) error VerifyOtp(ctx context.Context, msisdn, verificationCode *string) (bool, error) VerifyEmailOtp(ctx context.Context, email, verificationCode *string) (bool, error) GenerateRetryOTP(ctx context.Context, msisdn *string, retryStep int, appID *string) (string, error) EmailVerificationOtp(ctx context.Context, email *string) (string, error) GenerateOTP(ctx context.Context) (string, error) SendTemporaryPIN(ctx context.Context, input dto.TemporaryPIN) error }
ServiceOTP is an interface that defines all interactions with OTP service
type ServiceOTPImpl ¶
type ServiceOTPImpl struct {
// contains filtered or unexported fields
}
ServiceOTPImpl is an OTP generation and validation service
func NewService ¶
func NewService( mail mail.ServiceMail, sms sms.ServiceSMS, twilio twilio.ServiceTwilio, ) *ServiceOTPImpl
NewService initializes a valid OTP service First we fetch the dependencies from dep.yaml file. Since this service has a predefined set of dependencies, the same dependecies defined in the yaml should be defined in the service struct definition explicitly, No guess work.
func (ServiceOTPImpl) EmailVerificationOtp ¶
EmailVerificationOtp generates an OTP to the supplied email for verification
func (ServiceOTPImpl) GenerateAndSendOTP ¶
func (s ServiceOTPImpl) GenerateAndSendOTP(ctx context.Context, msisdn string, appID *string) (string, error)
GenerateAndSendOTP creates an OTP and sends it to the supplied phone number as a text message
func (ServiceOTPImpl) GenerateOTP ¶
func (s ServiceOTPImpl) GenerateOTP(ctx context.Context) (string, error)
GenerateOTP generates an OTP
func (ServiceOTPImpl) GenerateRetryOTP ¶
func (s ServiceOTPImpl) GenerateRetryOTP( ctx context.Context, msisdn *string, retryStep int, appID *string, ) (string, error)
GenerateRetryOTP generates fallback OTPs when Africa is talking sms fails
func (ServiceOTPImpl) SaveOTPToFirestore ¶
func (s ServiceOTPImpl) SaveOTPToFirestore(otp dto.OTP) error
SaveOTPToFirestore persists the supplied OTP
func (ServiceOTPImpl) SendOTP ¶
func (s ServiceOTPImpl) SendOTP( ctx context.Context, normalizedPhoneNumber string, code string, appID *string, ) (string, error)
SendOTP sends otp code message to specified number
func (ServiceOTPImpl) SendOTPToEmail ¶
func (s ServiceOTPImpl) SendOTPToEmail(ctx context.Context, msisdn, email *string, appID *string) (string, error)
SendOTPToEmail is a companion to GenerateAndSendOTP function It will send the generated OTP to the provided email address
func (ServiceOTPImpl) SendTemporaryPIN ¶
func (s ServiceOTPImpl) SendTemporaryPIN(ctx context.Context, input dto.TemporaryPIN) error
SendTemporaryPIN sends a temporary PIN message to user via whatsapp and SMS
func (ServiceOTPImpl) VerifyEmailOtp ¶
func (s ServiceOTPImpl) VerifyEmailOtp( ctx context.Context, email, verificationCode *string, ) (bool, error)
VerifyEmailOtp checks for the validity of the supplied OTP but does not invalidate it