Documentation ¶
Index ¶
- Constants
- func ConvertInterfaceMap(inp map[string]interface{}) map[string]string
- func ConvertStringMap(inp map[string]string) map[string]interface{}
- func GenerateRandomEmail() string
- func GenerateRandomWithNDigits(numberOfDigits int) (string, error)
- func IntSliceContains(s []int, e int) bool
- func IsMSISDNValid(msisdn string) bool
- func MapInterfaceToMapString(in map[string]interface{}) (map[string]string, error)
- func NormalizeMSISDN(msisdn string) (*string, error)
- func StringSliceContains(s []string, e string) bool
- func StructToMap(item interface{}) (map[string]interface{}, error)
- func ValidateAndSaveMSISDN(msisdn, verificationCode string, isUSSD bool, optIn bool, ...) (string, error)
- func ValidateMSISDN(msisdn, verificationCode string, isUSSD bool, ...) (string, error)
- type PhoneOptIn
- type USSDSessionLog
Constants ¶
const ( // OTPCollectionName is the name of the collection used to persist single // use verification codes on Firebase OTPCollectionName = "otps" // PhoneOptInCollectionName ... PhoneOptInCollectionName = "phone_opt_ins" //USSDSessionCollectionName ... USSDSessionCollectionName = "ussd_signup_sessions" )
Variables ¶
This section is empty.
Functions ¶
func ConvertInterfaceMap ¶ added in v0.0.6
ConvertInterfaceMap converts a map[string]interface{} to a map[string]string.
Any conversion errors are written out to the output map instead of being returned as error values.
New code is discouraged from using this function.
func ConvertStringMap ¶ added in v0.0.9
ConvertStringMap converts a map[string]string to a map[string]interface{}.
This is done mostly in order to conform to the gqlgen Graphql Map scalar.
func GenerateRandomEmail ¶ added in v0.0.4
func GenerateRandomEmail() string
GenerateRandomEmail allows us to get "unique" emails while still keeping one main be.well@bewell.co.ke email account
func GenerateRandomWithNDigits ¶ added in v0.0.4
GenerateRandomWithNDigits - given a digit generate random numbers
func IntSliceContains ¶ added in v0.0.5
IntSliceContains tests if a string is contained in a slice of strings
func IsMSISDNValid ¶
IsMSISDNValid uses regular expression to validate the a phone number
func MapInterfaceToMapString ¶ added in v0.0.9
MapInterfaceToMapString converts a map with interface{} values to one with string values.
It is used to convert a GraphQL (gqlgen) input Map to a map of strings for APIs that need map[string]string.
func NormalizeMSISDN ¶
NormalizeMSISDN validates the input phone number. For valid phone numbers, it normalizes them to international format e.g +2547........
func StringSliceContains ¶
StringSliceContains tests if a string is contained in a slice of strings
func StructToMap ¶ added in v0.0.4
StructToMap converts an object (struct) to a map.
WARNING: int inputs are converted to floats in the output map. This is an unintended consequence of converting through JSON.
In future, this should be deprecated.
func ValidateAndSaveMSISDN ¶
func ValidateAndSaveMSISDN( msisdn, verificationCode string, isUSSD bool, optIn bool, firestoreClient *firestore.Client) (string, error)
ValidateAndSaveMSISDN returns an error if the MSISDN format is wrong or the supplied verification code is not valid
func ValidateMSISDN ¶
func ValidateMSISDN( msisdn, verificationCode string, isUSSD bool, firestoreClient *firestore.Client) (string, error)
ValidateMSISDN returns an error if the MSISDN format is wrong or the supplied verification code is not valid Deprecated: Should implement `VerifyOTP` instead. This helps to confirm if a phonenumber is valid by verifying the code sent to it.
Types ¶
type PhoneOptIn ¶
type PhoneOptIn struct { MSISDN string `json:"msisdn" firestore:"msisdn"` OptedIn bool `json:"optedIn" firestore:"optedIn"` }
PhoneOptIn is used to persist and manage phone communication whitelists
type USSDSessionLog ¶
type USSDSessionLog struct { MSISDN string `json:"msisdn" firestore:"msisdn"` SessionID string `json:"sessionID" firestore:"sessionID"` }
USSDSessionLog is used to persist a log of USSD sessions