ussd

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LoginUserState handles workflow required to authenticate/login a user
	LoginUserState = 0
	//HomeMenuState represents inner submenu once user is logged in
	HomeMenuState = 5
	// ChangeUserPINState represents workflows required to set a user PIN
	ChangeUserPINState = 50
	// UserPINResetState represents workflows required to reset a forgotten user PIN
	UserPINResetState = 10
	// EmptyInput is used to load a default menu when user has not supplied any input
	EmptyInput = ""
	// GoBackHomeInput represents the user intention to go back to the main menu
	GoBackHomeInput = "0"
)
View Source
const (
	// ChangePINInput indicates the user intention to change their PIN
	ChangePINInput = "2"
	// ForgotPINInput indicates the user has forgotten their PIN and would like to reset it
	ForgotPINInput = "00"
	// ChangePINEnterNewPINState indicates the state at which user wants to set a new PIN
	ChangePINEnterNewPINState = 51
	// ChangePINProcessNewPINState indicates the state when the supplied PIN is being processed
	ChangePINProcessNewPINState = 52
	// ConfirmNewPINState indicates the state when a user is confirming a pin update
	ConfirmNewPINState = 53
	// PINResetEnterNewPINState indicates the state when the user wants to reset their PIN
	PINResetEnterNewPINState = 10
	// PINResetProcessState represents the state when the user has provided a wrong PIN
	PINResetProcessState = 11
	//ForgetPINResetState indicates the state when a use wants to reset PIN
	ForgetPINResetState = 13
	//ForgotPINVerifyDate indicates the state when a use wants to reset PIN
	ForgotPINVerifyDate = 15

	//USSDChooseToChangePIN indicates user chose to change PIN
	USSDChooseToChangePIN = "chose to change PIN"
	//USSDEnterOldPIN is the event when user enters their old PIN
	USSDEnterOldPIN = "entered old PIN"
	//USSDEnterNewPIN ...
	USSDEnterNewPIN = "entered a new 4 digit PIN"
	//USSDConfirmChangePIN ...
	USSDConfirmChangePIN = "confirmed new PIN"
	//USSDChooseToGoBackHome ...
	USSDChooseToGoBackHome = "chose to go back home"

	//USSDChooseToResetPIN ...
	USSDChooseToResetPIN = "chose to reset PIN"
	//USSDChooseToConfirmResetPIN ...
	USSDChooseToConfirmResetPIN = "confirm reset PIN"
	//USSDPINResetVerifyDate ...
	USSDPINResetVerifyDate = "verify date of birth"
)
View Source
const (
	// InitialState ...
	InitialState = 0
	// GetFirstNameState ...
	GetFirstNameState = 1
	// GetLastNameState ...
	GetLastNameState = 2
	// GetDOBState ...
	GetDOBState = 3
	// GetPINState ...
	GetPINState = 4
	// SaveRecordState ...
	SaveRecordState = 5
	// RegisterInput ...
	RegisterInput = "1"
	//RegOptOutInput ...
	RegOptOutInput = "2"
	//RegChangePINInput ...
	RegChangePINInput = "2"

	//USSDDialled ...
	USSDDialled = "dialled"
	//USSDSelectRegister ...
	USSDSelectRegister = "select register"
	//USSDEnterFirstname ...
	USSDEnterFirstname = "entered firstname"
	//USSDEnterLastname ...
	USSDEnterLastname = "entered lastname"
	//USSDEnterDOB ...
	USSDEnterDOB = "entered date of birth"
	//USSDEnterPIN ...
	USSDEnterPIN = "entered PIN"
	//USSDConfirmPIN ...
	USSDConfirmPIN = "confirmed PIN"
	//USSDOptOut ...
	USSDOptOut = "opted out"
)
View Source
const (
	// OptOutFromMarketingInput indicates users who don't want to be send marketing sms(messages)
	OptOutFromMarketingInput = "1"
)
View Source
const (
	//USSDLoginDialEvent ...
	USSDLoginDialEvent = "dialled to login"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Impl

type Impl struct {
	// contains filtered or unexported fields
}

Impl represents usecase implementation

func (*Impl) AddAITSessionDetails

func (u *Impl) AddAITSessionDetails(ctx context.Context, input *dto.SessionDetails) (*domain.USSDLeadDetails, error)

AddAITSessionDetails persists USSD details

func (*Impl) ChangeUSSDUserPIN

func (u *Impl) ChangeUSSDUserPIN(
	ctx context.Context,
	phone string,
	pin string,
) (bool, error)

ChangeUSSDUserPIN updates user's pin with the newly supplied pin via USSD

func (*Impl) CreateEmptyCustomerProfile

func (u *Impl) CreateEmptyCustomerProfile(ctx context.Context, profileID string) (*profileutils.Customer, error)

CreateEmptyCustomerProfile ...

func (*Impl) CreateUsddUserProfile

func (u *Impl) CreateUsddUserProfile(ctx context.Context, phoneNumber string, PIN string, userProfile *dto.UserProfileInput) error

CreateUsddUserProfile creates and updates a user profile

func (*Impl) CreateUserProfile

func (u *Impl) CreateUserProfile(ctx context.Context, phoneNumber string, uid string) (*profileutils.UserProfile, error)

CreateUserProfile ...

func (*Impl) GetOrCreatePhoneNumberUser

func (u *Impl) GetOrCreatePhoneNumberUser(ctx context.Context, phone string) (*dto.CreatedUserResponse, error)

GetOrCreatePhoneNumberUser ...

func (*Impl) GetOrCreateSessionState

func (u *Impl) GetOrCreateSessionState(ctx context.Context, payload *dto.SessionDetails) (*domain.USSDLeadDetails, error)

GetOrCreateSessionState is used to set or return a user session

func (*Impl) GetUserProfileByPrimaryPhoneNumber

func (u *Impl) GetUserProfileByPrimaryPhoneNumber(ctx context.Context, phoneNumber string, suspend bool) (*profileutils.UserProfile, error)

GetUserProfileByPrimaryPhoneNumber ...

func (*Impl) HandleChangePIN

func (u *Impl) HandleChangePIN(ctx context.Context, session *domain.USSDLeadDetails, userResponse string) string

HandleChangePIN represents workflow used to change a user PIN

func (*Impl) HandleHomeMenu

func (u *Impl) HandleHomeMenu(ctx context.Context, level int, session *domain.USSDLeadDetails, userResponse string) string

HandleHomeMenu represents the default home menu

func (*Impl) HandleLogin

func (u *Impl) HandleLogin(ctx context.Context, session *domain.USSDLeadDetails, userResponse string) string

HandleLogin represents the workflow for authenticating a user

func (*Impl) HandlePINReset

func (u *Impl) HandlePINReset(ctx context.Context, session *domain.USSDLeadDetails, userResponse string) string

HandlePINReset represents workflow used to reset to a user PIN

func (*Impl) HandleResponseFromUSSDGateway

func (u *Impl) HandleResponseFromUSSDGateway(ctx context.Context, payload *dto.SessionDetails) string

HandleResponseFromUSSDGateway receives and processes the USSD response from the USSD gateway

func (*Impl) HandleUserRegistration

func (u *Impl) HandleUserRegistration(ctx context.Context, session *domain.USSDLeadDetails, userResponse string) string

HandleUserRegistration ...

func (*Impl) LoginInUser

func (u *Impl) LoginInUser(
	ctx context.Context,
	phone string,
	PIN string,
	flavour feedlib.Flavour,
) (bool, error)

LoginInUser authenticates a user to allow them proceed to the home menu

func (*Impl) RemoveUserByPhoneNumber

func (u *Impl) RemoveUserByPhoneNumber(ctx context.Context, phone string) error

RemoveUserByPhoneNumber ...

func (*Impl) ResetPinMenu

func (u *Impl) ResetPinMenu() string

ResetPinMenu ...

func (*Impl) SaveUSSDEvent

func (u *Impl) SaveUSSDEvent(ctx context.Context, input *dto.USSDEvent) (*dto.USSDEvent, error)

SaveUSSDEvent saves USSD event in the database

func (*Impl) SetUSSDUserPin

func (u *Impl) SetUSSDUserPin(ctx context.Context, phoneNumber string, PIN string) error

SetUSSDUserPin sets user pin when a user registers via USSD

func (*Impl) SetUserPIN

func (u *Impl) SetUserPIN(ctx context.Context, pin string, profileID string) (bool, error)

SetUserPIN ...

func (*Impl) UpdateBioData

func (u *Impl) UpdateBioData(ctx context.Context, id string, data profileutils.BioData) error

UpdateBioData ...

func (*Impl) UpdateSessionLevel

func (u *Impl) UpdateSessionLevel(ctx context.Context, level int, sessionID string) error

UpdateSessionLevel updates user current level of interaction with USSD

func (*Impl) UpdateSessionPIN

func (u *Impl) UpdateSessionPIN(ctx context.Context, pin string, sessionID string) (*domain.USSDLeadDetails, error)

UpdateSessionPIN updates user current session PIN

func (*Impl) WelcomeMenu

func (u *Impl) WelcomeMenu() string

WelcomeMenu represents the default welcome submenu

type Usecase

type Usecase interface {
	HandleResponseFromUSSDGateway(context context.Context, input *dto.SessionDetails) string
	HandleUserRegistration(ctx context.Context, sessionDetails *domain.USSDLeadDetails, userResponse string) string
	HandleHomeMenu(ctx context.Context, level int, session *domain.USSDLeadDetails, userResponse string) string
	CreateUsddUserProfile(ctx context.Context, phoneNumber string, PIN string, userProfile *dto.UserProfileInput) error
	HandleLogin(ctx context.Context, session *domain.USSDLeadDetails, userResponse string) string
	// session usecases
	GetOrCreateSessionState(ctx context.Context, payload *dto.SessionDetails) (*domain.USSDLeadDetails, error)
	AddAITSessionDetails(ctx context.Context, input *dto.SessionDetails) (*domain.USSDLeadDetails, error)
	UpdateSessionLevel(ctx context.Context, level int, sessionID string) error
	UpdateSessionPIN(ctx context.Context, pin string, sessionID string) (*domain.USSDLeadDetails, error)
	// USSD PIN usecases
	HandleChangePIN(ctx context.Context, session *domain.USSDLeadDetails, userResponse string) string
	HandlePINReset(ctx context.Context, session *domain.USSDLeadDetails, userResponse string) string
	SetUSSDUserPin(ctx context.Context, phoneNumber string, PIN string) error
	ChangeUSSDUserPIN(ctx context.Context, phone string, pin string) (bool, error)

	// Onboarding
	GetOrCreatePhoneNumberUser(ctx context.Context, phone string) (*dto.CreatedUserResponse, error)
	CreateUserProfile(ctx context.Context, phoneNumber, uid string) (*profileutils.UserProfile, error)
	CreateEmptyCustomerProfile(ctx context.Context, profileID string) (*profileutils.Customer, error)
	UpdateBioData(ctx context.Context, id string, data profileutils.BioData) error
	GetUserProfileByPrimaryPhoneNumber(ctx context.Context, phoneNumber string, suspend bool) (*profileutils.UserProfile, error)
	RemoveUserByPhoneNumber(ctx context.Context, phone string) error
	SetUserPIN(ctx context.Context, pin string, profileID string) (bool, error)
	//USSD Metrics Event
	SaveUSSDEvent(ctx context.Context, input *dto.USSDEvent) (*dto.USSDEvent, error)
}

Usecase represent the logic involved in processing USSD requests

func NewUssdUsecases

NewUssdUsecases returns a new USSD usecase

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL