Documentation
¶
Index ¶
- Constants
- type Interactor
- type LoginUseCases
- type LoginUseCasesImpl
- func (l *LoginUseCasesImpl) LoginAsAnonymous(ctx context.Context) (*profileutils.AuthCredentialResponse, error)
- func (l *LoginUseCasesImpl) LoginByPhone(ctx context.Context, phone string, PIN string, flavour feedlib.Flavour) (*profileutils.UserResponse, error)
- func (l *LoginUseCasesImpl) RefreshToken(ctx context.Context, token string) (*profileutils.AuthCredentialResponse, error)
- func (l *LoginUseCasesImpl) ResumeWithPin(ctx context.Context, pin string) (bool, error)
- type ProfileUseCase
- type ProfileUseCaseImpl
- func (p *ProfileUseCaseImpl) AddAddress(ctx context.Context, input dto.UserAddressInput, ...) (*profileutils.Address, error)
- func (p *ProfileUseCaseImpl) AddAdminPermsToUser(ctx context.Context, phone string) error
- func (p *ProfileUseCaseImpl) AddRoleToUser(ctx context.Context, phone string, role profileutils.RoleType) error
- func (p *ProfileUseCaseImpl) CheckEmailExists(ctx context.Context, email string) (bool, error)
- func (p *ProfileUseCaseImpl) CheckPhoneExists(ctx context.Context, phone string) (bool, error)
- func (p *ProfileUseCaseImpl) ConfirmedEmailAddresses(ctx context.Context, UIDs []string) (map[string][]string, error)
- func (p *ProfileUseCaseImpl) ConfirmedPhoneNumbers(ctx context.Context, UIDs []string) (map[string][]string, error)
- func (p *ProfileUseCaseImpl) DeleteFavoriteNavActions(ctx context.Context, title string) (bool, error)
- func (p *ProfileUseCaseImpl) FindUserByPhone(ctx context.Context, phoneNumber string) (*profileutils.UserProfile, error)
- func (p *ProfileUseCaseImpl) FindUsersByPhone(ctx context.Context, phoneNumber string) ([]*profileutils.UserProfile, error)
- func (p *ProfileUseCaseImpl) GetAddresses(ctx context.Context) (*domain.UserAddresses, error)
- func (p *ProfileUseCaseImpl) GetAllUserProfiles(ctx context.Context) ([]*profileutils.UserProfile, error)
- func (p *ProfileUseCaseImpl) GetNavigationActions(ctx context.Context) (*dto.GroupedNavigationActions, error)
- func (p *ProfileUseCaseImpl) GetProfileByID(ctx context.Context, id *string) (*profileutils.UserProfile, error)
- func (p *ProfileUseCaseImpl) GetUserCommunicationsSettings(ctx context.Context) (*profileutils.UserCommunicationsSetting, error)
- func (p *ProfileUseCaseImpl) GetUserProfileAttributes(ctx context.Context, UIDs []string, attribute string) (map[string][]string, error)
- func (p *ProfileUseCaseImpl) GetUserProfileByPhoneOrEmail(ctx context.Context, payload *dto.RetrieveUserProfileInput) (*profileutils.UserProfile, error)
- func (p *ProfileUseCaseImpl) GetUserProfileByUID(ctx context.Context, UID string) (*profileutils.UserProfile, error)
- func (p *ProfileUseCaseImpl) MaskPhoneNumbers(phones []string) []string
- func (p *ProfileUseCaseImpl) ProfileAttributes(ctx context.Context, UIDs []string, attribute string) (map[string][]string, error)
- func (p *ProfileUseCaseImpl) RefreshNavigationActions(ctx context.Context) (*profileutils.NavigationActions, error)
- func (p *ProfileUseCaseImpl) RemoveAdminPermsToUser(ctx context.Context, phone string) error
- func (p *ProfileUseCaseImpl) RemoveRoleToUser(ctx context.Context, phone string) error
- func (p *ProfileUseCaseImpl) RetireSecondaryEmailAddress(ctx context.Context, emailAddresses []string) (bool, error)
- func (p *ProfileUseCaseImpl) RetireSecondaryPhoneNumbers(ctx context.Context, phoneNumbers []string) (bool, error)
- func (p *ProfileUseCaseImpl) SaveFavoriteNavActions(ctx context.Context, title string) (bool, error)
- func (p *ProfileUseCaseImpl) SetPrimaryEmailAddress(ctx context.Context, emailAddress string, otp string) error
- func (p *ProfileUseCaseImpl) SetPrimaryPhoneNumber(ctx context.Context, phoneNumber string, otp string, useContext bool) error
- func (p *ProfileUseCaseImpl) SetUserCommunicationsSettings(ctx context.Context, allowWhatsApp *bool, allowTextSms *bool, allowPush *bool, ...) (*profileutils.UserCommunicationsSetting, error)
- func (p *ProfileUseCaseImpl) SetupAsExperimentParticipant(ctx context.Context, participate *bool) (bool, error)
- func (p *ProfileUseCaseImpl) SwitchUserFlaggedFeatures(ctx context.Context, phoneNumber string) (*dto.OKResp, error)
- func (p *ProfileUseCaseImpl) UpdateBioData(ctx context.Context, data profileutils.BioData) error
- func (p *ProfileUseCaseImpl) UpdatePermissions(ctx context.Context, perms []profileutils.PermissionType) error
- func (p *ProfileUseCaseImpl) UpdatePhotoUploadID(ctx context.Context, uploadID string) error
- func (p *ProfileUseCaseImpl) UpdatePrimaryEmailAddress(ctx context.Context, emailAddress string) error
- func (p *ProfileUseCaseImpl) UpdatePrimaryPhoneNumber(ctx context.Context, phone string, useContext bool) error
- func (p *ProfileUseCaseImpl) UpdatePushTokens(ctx context.Context, pushToken string, retire bool) error
- func (p *ProfileUseCaseImpl) UpdateSecondaryEmailAddresses(ctx context.Context, emailAddresses []string) error
- func (p *ProfileUseCaseImpl) UpdateSecondaryPhoneNumbers(ctx context.Context, phoneNumbers []string) error
- func (p *ProfileUseCaseImpl) UpdateSuspended(ctx context.Context, status bool, phone string, useContext bool) error
- func (p *ProfileUseCaseImpl) UpdateUserName(ctx context.Context, userName string) error
- func (p *ProfileUseCaseImpl) UpdateVerifiedIdentifiers(ctx context.Context, identifiers []profileutils.VerifiedIdentifier) error
- func (p *ProfileUseCaseImpl) UpdateVerifiedUIDS(ctx context.Context, uids []string) error
- func (p *ProfileUseCaseImpl) UserProfile(ctx context.Context) (*profileutils.UserProfile, error)
- func (p *ProfileUseCaseImpl) ValidFCMTokens(ctx context.Context, UIDs []string) (map[string][]string, error)
- type RoleUseCase
- type RoleUseCaseImpl
- func (r *RoleUseCaseImpl) ActivateRole(ctx context.Context, roleID string) (*dto.RoleOutput, error)
- func (r *RoleUseCaseImpl) AddPermissionsToRole(ctx context.Context, input dto.RolePermissionInput) (*dto.RoleOutput, error)
- func (r RoleUseCaseImpl) AssignMultipleRoles(ctx context.Context, userID string, roleIDs []string) (bool, error)
- func (r *RoleUseCaseImpl) AssignRole(ctx context.Context, userID string, roleID string) (bool, error)
- func (r *RoleUseCaseImpl) CheckPermission(ctx context.Context, uid string, permission profileutils.Permission) (bool, error)
- func (r *RoleUseCaseImpl) CreateRole(ctx context.Context, input dto.RoleInput) (*dto.RoleOutput, error)
- func (r *RoleUseCaseImpl) CreateUnauthorizedRole(ctx context.Context, input dto.RoleInput) (*dto.RoleOutput, error)
- func (r *RoleUseCaseImpl) DeactivateRole(ctx context.Context, roleID string) (*dto.RoleOutput, error)
- func (r *RoleUseCaseImpl) DeleteRole(ctx context.Context, roleID string) (bool, error)
- func (r *RoleUseCaseImpl) FindRoleByName(ctx context.Context, roleName *string) ([]*dto.RoleOutput, error)
- func (r *RoleUseCaseImpl) GetAllPermissions(ctx context.Context) ([]*profileutils.Permission, error)
- func (r *RoleUseCaseImpl) GetAllRoles(ctx context.Context) ([]*dto.RoleOutput, error)
- func (r *RoleUseCaseImpl) GetRoleByName(ctx context.Context, name string) (*dto.RoleOutput, error)
- func (r RoleUseCaseImpl) GetRolesByIDs(ctx context.Context, roleIDs []string) ([]*dto.RoleOutput, error)
- func (r *RoleUseCaseImpl) RevokeRole(ctx context.Context, userID string, roleID string, reason string) (bool, error)
- func (r *RoleUseCaseImpl) RevokeRolePermission(ctx context.Context, input dto.RolePermissionInput) (*dto.RoleOutput, error)
- func (r *RoleUseCaseImpl) UnauthorizedDeleteRole(ctx context.Context, roleID string) (bool, error)
- func (r *RoleUseCaseImpl) UpdateRolePermissions(ctx context.Context, input dto.RolePermissionInput) (*dto.RoleOutput, error)
- type SignUpUseCases
- type SignUpUseCasesImpl
- func (s *SignUpUseCasesImpl) CompleteSignup(ctx context.Context, flavour feedlib.Flavour) (bool, error)
- func (s *SignUpUseCasesImpl) CreateUserByPhone(ctx context.Context, input *dto.SignUpInput) (*profileutils.UserResponse, error)
- func (s *SignUpUseCasesImpl) GetUserRecoveryPhoneNumbers(ctx context.Context, phone string) (*dto.AccountRecoveryPhonesResponse, error)
- func (s *SignUpUseCasesImpl) RegisterPushToken(ctx context.Context, token string) (bool, error)
- func (s *SignUpUseCasesImpl) RegisterUser(ctx context.Context, input dto.RegisterUserInput) (*profileutils.UserProfile, error)
- func (s *SignUpUseCasesImpl) RemoveUserByPhoneNumber(ctx context.Context, phone string) error
- func (s *SignUpUseCasesImpl) RetirePushToken(ctx context.Context, token string) (bool, error)
- func (s *SignUpUseCasesImpl) SetPhoneAsPrimary(ctx context.Context, phone, otp string) (bool, error)
- func (s *SignUpUseCasesImpl) UpdateUserProfile(ctx context.Context, input *dto.UserProfileInput) (*profileutils.UserProfile, error)
- func (s *SignUpUseCasesImpl) VerifyPhoneNumber(ctx context.Context, phone string, appID *string) (*profileutils.OtpResponse, error)
- type SurveyUseCases
- type SurveyUseCasesImpl
- type TesterUseCases
- type UserPINUseCases
- type UserPinUseCaseImpl
- func (u *UserPinUseCaseImpl) ChangeUserPIN(ctx context.Context, phone string, pin string) (bool, error)
- func (u *UserPinUseCaseImpl) CheckHasPIN(ctx context.Context, profileID string) (bool, error)
- func (u *UserPinUseCaseImpl) RequestPINReset(ctx context.Context, phone string, appID *string) (*profileutils.OtpResponse, error)
- func (u *UserPinUseCaseImpl) ResetUserPIN(ctx context.Context, phone string, PIN string, OTP string) (bool, error)
- func (u *UserPinUseCaseImpl) SetUserPIN(ctx context.Context, pin string, profileID string) (bool, error)
- func (u *UserPinUseCaseImpl) SetUserTempPIN(ctx context.Context, profileID string) (string, error)
Constants ¶
const ( // EmailsAttribute is an attribute that represents // a user profile's email addresses EmailsAttribute = "emails" // PhoneNumbersAttribute is an attribute that represents // a user profile's phone numbers PhoneNumbersAttribute = "phonenumbers" // FCMTokensAttribute is an attribute that represents // a user profile's FCM push tokens FCMTokensAttribute = "tokens" )
const VerifyEmailNudgeTitle = "Add Primary Email Address"
VerifyEmailNudgeTitle is the title defined in the `engagement service` for the `VerifyEmail` nudge
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interactor ¶ added in v0.0.2
type Interactor struct { LoginUseCases ProfileUseCase RoleUseCase SignUpUseCases SurveyUseCases UserPINUseCases admin.Usecase }
Interactor is an implementation of the usecases interface
func NewUsecasesInteractor ¶ added in v0.0.2
func NewUsecasesInteractor(infrastructure infrastructure.Infrastructure, baseExtension extension.BaseExtension, pinsExtension extension.PINExtension) Interactor
NewUsecasesInteractor initializes a new usecases interactor
type LoginUseCases ¶
type LoginUseCases interface { LoginByPhone( ctx context.Context, phone string, PIN string, flavour feedlib.Flavour, ) (*profileutils.UserResponse, error) RefreshToken(ctx context.Context, token string) (*profileutils.AuthCredentialResponse, error) LoginAsAnonymous(ctx context.Context) (*profileutils.AuthCredentialResponse, error) ResumeWithPin(ctx context.Context, pin string) (bool, error) }
LoginUseCases represents all the business logic involved in logging in a user and managing their authorization credentials.
func NewLoginUseCases ¶
func NewLoginUseCases( i infrastructure.Infrastructure, p ProfileUseCase, ext extension.BaseExtension, pin extension.PINExtension) LoginUseCases
NewLoginUseCases initializes a new sign up usecase
type LoginUseCasesImpl ¶
type LoginUseCasesImpl struct {
// contains filtered or unexported fields
}
LoginUseCasesImpl represents the usecase implementation object
func (*LoginUseCasesImpl) LoginAsAnonymous ¶
func (l *LoginUseCasesImpl) LoginAsAnonymous( ctx context.Context, ) (*profileutils.AuthCredentialResponse, error)
LoginAsAnonymous logs in a user as anonymous. This anonymous user will not have a userProfile since we don't have their phone number. All that we return is auth credentials and an error
func (*LoginUseCasesImpl) LoginByPhone ¶
func (l *LoginUseCasesImpl) LoginByPhone( ctx context.Context, phone string, PIN string, flavour feedlib.Flavour, ) (*profileutils.UserResponse, error)
LoginByPhone returns credentials that are used to log a user in provided the phone number and pin supplied are correct
func (*LoginUseCasesImpl) RefreshToken ¶
func (l *LoginUseCasesImpl) RefreshToken(ctx context.Context, token string) (*profileutils.AuthCredentialResponse, error)
RefreshToken takes a custom Firebase refresh token and tries to fetch an ID token and returns auth credentials if successful Otherwise, an error is returned
func (*LoginUseCasesImpl) ResumeWithPin ¶
ResumeWithPin called by the frontend check whether the currently logged in user is the one trying to get access to app
type ProfileUseCase ¶
type ProfileUseCase interface { // profile related UserProfile(ctx context.Context) (*profileutils.UserProfile, error) GetProfileByID(ctx context.Context, id *string) (*profileutils.UserProfile, error) UpdateUserName(ctx context.Context, userName string) error UpdatePrimaryPhoneNumber(ctx context.Context, phoneNumber string, useContext bool) error UpdatePrimaryEmailAddress(ctx context.Context, emailAddress string) error UpdateSecondaryPhoneNumbers(ctx context.Context, phoneNumbers []string) error UpdateSecondaryEmailAddresses(ctx context.Context, emailAddresses []string) error UpdateVerifiedIdentifiers( ctx context.Context, identifiers []profileutils.VerifiedIdentifier, ) error UpdateVerifiedUIDS(ctx context.Context, uids []string) error UpdateSuspended(ctx context.Context, status bool, phoneNumber string, useContext bool) error UpdatePhotoUploadID(ctx context.Context, uploadID string) error UpdatePushTokens(ctx context.Context, pushToken string, retire bool) error UpdatePermissions(ctx context.Context, perms []profileutils.PermissionType) error AddAdminPermsToUser(ctx context.Context, phone string) error RemoveAdminPermsToUser(ctx context.Context, phone string) error AddRoleToUser(ctx context.Context, phone string, role profileutils.RoleType) error RemoveRoleToUser(ctx context.Context, phone string) error UpdateBioData(ctx context.Context, data profileutils.BioData) error GetUserProfileByUID( ctx context.Context, UID string, ) (*profileutils.UserProfile, error) GetUserProfileByPhoneOrEmail( ctx context.Context, payload *dto.RetrieveUserProfileInput, ) (*profileutils.UserProfile, error) GetAllUserProfiles( ctx context.Context, ) ([]*profileutils.UserProfile, error) // masks phone number. MaskPhoneNumbers(phones []string) []string // called to set the primary phone number of a specific profile. // useContext is used to mark under which scenario the method is been called. SetPrimaryPhoneNumber( ctx context.Context, phoneNumber string, otp string, useContext bool, ) error SetPrimaryEmailAddress( ctx context.Context, emailAddress string, otp string, ) error // checks whether a phone number has been registered by another user. Checks both primary and // secondary phone numbers. If the the phone number is foreign, it returns false CheckPhoneExists(ctx context.Context, phone string) (bool, error) // check whether a email has been registered by another user. Checks both primary and // secondary emails. If the the phone number is foreign, it returns false CheckEmailExists(ctx context.Context, email string) (bool, error) // called to remove specific secondary phone numbers from the user's profile.' RetireSecondaryPhoneNumbers(ctx context.Context, toRemovePhoneNumbers []string) (bool, error) // called to remove specific secondary email addresses from the user's profile. RetireSecondaryEmailAddress(ctx context.Context, toRemoveEmails []string) (bool, error) GetUserProfileAttributes( ctx context.Context, UIDs []string, attribute string, ) (map[string][]string, error) ConfirmedEmailAddresses( ctx context.Context, UIDs []string, ) (map[string][]string, error) ConfirmedPhoneNumbers( ctx context.Context, UIDs []string, ) (map[string][]string, error) ValidFCMTokens( ctx context.Context, UIDs []string, ) (map[string][]string, error) ProfileAttributes( ctx context.Context, UIDs []string, attribute string, ) (map[string][]string, error) SetupAsExperimentParticipant(ctx context.Context, participate *bool) (bool, error) AddAddress( ctx context.Context, input dto.UserAddressInput, addressType enumutils.AddressType, ) (*profileutils.Address, error) GetAddresses(ctx context.Context) (*domain.UserAddresses, error) GetUserCommunicationsSettings( ctx context.Context, ) (*profileutils.UserCommunicationsSetting, error) SetUserCommunicationsSettings( ctx context.Context, allowWhatsApp *bool, allowTextSms *bool, allowPush *bool, allowEmail *bool, ) (*profileutils.UserCommunicationsSetting, error) SwitchUserFlaggedFeatures(ctx context.Context, phoneNumber string) (*dto.OKResp, error) FindUserByPhone(ctx context.Context, phoneNumber string) (*profileutils.UserProfile, error) FindUsersByPhone(ctx context.Context, phoneNumber string) ([]*profileutils.UserProfile, error) }
ProfileUseCase represents all the profile business logic
func NewProfileUseCase ¶
func NewProfileUseCase( infrastructure infrastructure.Infrastructure, ext extension.BaseExtension, ) ProfileUseCase
NewProfileUseCase returns a new a onboarding usecase
type ProfileUseCaseImpl ¶
type ProfileUseCaseImpl struct {
// contains filtered or unexported fields
}
ProfileUseCaseImpl represents usecase implementation object
func (*ProfileUseCaseImpl) AddAddress ¶
func (p *ProfileUseCaseImpl) AddAddress( ctx context.Context, input dto.UserAddressInput, addressType enumutils.AddressType, ) (*profileutils.Address, error)
AddAddress adds a user's home or work address to their user's profile
func (*ProfileUseCaseImpl) AddAdminPermsToUser ¶
func (p *ProfileUseCaseImpl) AddAdminPermsToUser(ctx context.Context, phone string) error
AddAdminPermsToUser updates the profiles permissions
func (*ProfileUseCaseImpl) AddRoleToUser ¶
func (p *ProfileUseCaseImpl) AddRoleToUser( ctx context.Context, phone string, role profileutils.RoleType, ) error
AddRoleToUser updates the profiles role and permissions
func (*ProfileUseCaseImpl) CheckEmailExists ¶
CheckEmailExists checks whether a email has been registered by another user. Checks both primary and secondary emails.
func (*ProfileUseCaseImpl) CheckPhoneExists ¶
CheckPhoneExists checks whether a phone number has been registered by another user. Checks both primary and secondary phone numbers.
func (*ProfileUseCaseImpl) ConfirmedEmailAddresses ¶
func (p *ProfileUseCaseImpl) ConfirmedEmailAddresses( ctx context.Context, UIDs []string, ) (map[string][]string, error)
ConfirmedEmailAddresses returns verified email addresses for each of the UID in the slice of UIDs provided
func (*ProfileUseCaseImpl) ConfirmedPhoneNumbers ¶
func (p *ProfileUseCaseImpl) ConfirmedPhoneNumbers( ctx context.Context, UIDs []string, ) (map[string][]string, error)
ConfirmedPhoneNumbers returns verified phone numbers for each of the UID in the slice of UIDs provided
func (*ProfileUseCaseImpl) DeleteFavoriteNavActions ¶
func (p *ProfileUseCaseImpl) DeleteFavoriteNavActions( ctx context.Context, title string, ) (bool, error)
DeleteFavoriteNavActions removes a booked marked navigation action from user profile
func (*ProfileUseCaseImpl) FindUserByPhone ¶ added in v0.0.2
func (p *ProfileUseCaseImpl) FindUserByPhone(ctx context.Context, phoneNumber string) (*profileutils.UserProfile, error)
FindUserByPhone searches for a user using a phone number
func (*ProfileUseCaseImpl) FindUsersByPhone ¶ added in v0.0.19
func (p *ProfileUseCaseImpl) FindUsersByPhone(ctx context.Context, phoneNumber string) ([]*profileutils.UserProfile, error)
FindUsersByPhone searches for a user using a phone number
func (*ProfileUseCaseImpl) GetAddresses ¶
func (p *ProfileUseCaseImpl) GetAddresses( ctx context.Context, ) (*domain.UserAddresses, error)
GetAddresses returns a user's home and work addresses
func (*ProfileUseCaseImpl) GetAllUserProfiles ¶ added in v0.0.30
func (p *ProfileUseCaseImpl) GetAllUserProfiles(ctx context.Context) ([]*profileutils.UserProfile, error)
GetAllUserProfiles retrieves all profile for all users
func (*ProfileUseCaseImpl) GetNavigationActions ¶ added in v0.0.2
func (p *ProfileUseCaseImpl) GetNavigationActions( ctx context.Context, ) (*dto.GroupedNavigationActions, error)
GetNavigationActions is the new method to get navigation actions based on user roles and permissions
func (*ProfileUseCaseImpl) GetProfileByID ¶
func (p *ProfileUseCaseImpl) GetProfileByID( ctx context.Context, id *string, ) (*profileutils.UserProfile, error)
GetProfileByID returns the profile identified by the indicated ID
func (*ProfileUseCaseImpl) GetUserCommunicationsSettings ¶
func (p *ProfileUseCaseImpl) GetUserCommunicationsSettings( ctx context.Context, ) (*profileutils.UserCommunicationsSetting, error)
GetUserCommunicationsSettings retrives the logged in user communications settings.
func (*ProfileUseCaseImpl) GetUserProfileAttributes ¶
func (p *ProfileUseCaseImpl) GetUserProfileAttributes( ctx context.Context, UIDs []string, attribute string, ) (map[string][]string, error)
GetUserProfileAttributes takes a slice of UIDs and for each UID, it fetches the user profiles confirmed emails, phone numbers and FCM push tokens
func (*ProfileUseCaseImpl) GetUserProfileByPhoneOrEmail ¶ added in v0.0.2
func (p *ProfileUseCaseImpl) GetUserProfileByPhoneOrEmail(ctx context.Context, payload *dto.RetrieveUserProfileInput) (*profileutils.UserProfile, error)
GetUserProfileByPhoneOrEmail retrieves user profie by email address is they have one
func (*ProfileUseCaseImpl) GetUserProfileByUID ¶
func (p *ProfileUseCaseImpl) GetUserProfileByUID( ctx context.Context, UID string, ) (*profileutils.UserProfile, error)
GetUserProfileByUID retrieves the profile of the logged in user, if they have one
func (*ProfileUseCaseImpl) MaskPhoneNumbers ¶
func (p *ProfileUseCaseImpl) MaskPhoneNumbers(phones []string) []string
MaskPhoneNumbers masks phone number. the masked phone numbers will be in the form +254700***123
func (*ProfileUseCaseImpl) ProfileAttributes ¶
func (p *ProfileUseCaseImpl) ProfileAttributes( ctx context.Context, UIDs []string, attribute string, ) (map[string][]string, error)
ProfileAttributes retrieves the user profiles confirmed emails, phone numbers and FCM push tokens
func (*ProfileUseCaseImpl) RefreshNavigationActions ¶
func (p *ProfileUseCaseImpl) RefreshNavigationActions( ctx context.Context, ) (*profileutils.NavigationActions, error)
RefreshNavigationActions gets user navigation actions only
func (*ProfileUseCaseImpl) RemoveAdminPermsToUser ¶
func (p *ProfileUseCaseImpl) RemoveAdminPermsToUser(ctx context.Context, phone string) error
RemoveAdminPermsToUser updates the profiles permissions by removing the admin permissions This also flips back userProfile field IsAdmin to false
func (*ProfileUseCaseImpl) RemoveRoleToUser ¶
func (p *ProfileUseCaseImpl) RemoveRoleToUser(ctx context.Context, phone string) error
RemoveRoleToUser updates the profiles role and permissions by setting roles to default
func (*ProfileUseCaseImpl) RetireSecondaryEmailAddress ¶
func (p *ProfileUseCaseImpl) RetireSecondaryEmailAddress( ctx context.Context, emailAddresses []string, ) (bool, error)
RetireSecondaryEmailAddress removes specific secondary email addresses from the user's profile.
func (*ProfileUseCaseImpl) RetireSecondaryPhoneNumbers ¶
func (p *ProfileUseCaseImpl) RetireSecondaryPhoneNumbers( ctx context.Context, phoneNumbers []string, ) (bool, error)
RetireSecondaryPhoneNumbers overwrites an existing secondary phone number, if any, with the provided phone number.
func (*ProfileUseCaseImpl) SaveFavoriteNavActions ¶
func (p *ProfileUseCaseImpl) SaveFavoriteNavActions( ctx context.Context, title string, ) (bool, error)
SaveFavoriteNavActions saves the users favorite navigation actions
func (*ProfileUseCaseImpl) SetPrimaryEmailAddress ¶
func (p *ProfileUseCaseImpl) SetPrimaryEmailAddress( ctx context.Context, emailAddress string, otp string, ) error
SetPrimaryEmailAddress set the primary email address of the user after verifying the otp code
func (*ProfileUseCaseImpl) SetPrimaryPhoneNumber ¶
func (p *ProfileUseCaseImpl) SetPrimaryPhoneNumber( ctx context.Context, phoneNumber string, otp string, useContext bool, ) error
SetPrimaryPhoneNumber set the primary phone number of the user after verifying the otp code
func (*ProfileUseCaseImpl) SetUserCommunicationsSettings ¶
func (p *ProfileUseCaseImpl) SetUserCommunicationsSettings( ctx context.Context, allowWhatsApp *bool, allowTextSms *bool, allowPush *bool, allowEmail *bool, ) (*profileutils.UserCommunicationsSetting, error)
SetUserCommunicationsSettings sets the user communication settings
func (*ProfileUseCaseImpl) SetupAsExperimentParticipant ¶
func (p *ProfileUseCaseImpl) SetupAsExperimentParticipant( ctx context.Context, participate *bool, ) (bool, error)
SetupAsExperimentParticipant sets up the logged-in user as an experiment participant. An experiment participant will be able to see unstable or otherwise flaged-feature in the UI of the app
func (*ProfileUseCaseImpl) SwitchUserFlaggedFeatures ¶
func (p *ProfileUseCaseImpl) SwitchUserFlaggedFeatures( ctx context.Context, phoneNumber string, ) (*dto.OKResp, error)
SwitchUserFlaggedFeatures flips the user as opt-in or opt-out to flagged features once flipped the, frontend will receive an updated user profile when the person logs in again
func (*ProfileUseCaseImpl) UpdateBioData ¶
func (p *ProfileUseCaseImpl) UpdateBioData(ctx context.Context, data profileutils.BioData) error
UpdateBioData updates primary biodata of a specific user profile
func (*ProfileUseCaseImpl) UpdatePermissions ¶
func (p *ProfileUseCaseImpl) UpdatePermissions( ctx context.Context, perms []profileutils.PermissionType, ) error
UpdatePermissions updates the profiles permissions
func (*ProfileUseCaseImpl) UpdatePhotoUploadID ¶
func (p *ProfileUseCaseImpl) UpdatePhotoUploadID(ctx context.Context, uploadID string) error
UpdatePhotoUploadID updates photouploadid attribute of a specific user profile
func (*ProfileUseCaseImpl) UpdatePrimaryEmailAddress ¶
func (p *ProfileUseCaseImpl) UpdatePrimaryEmailAddress( ctx context.Context, emailAddress string, ) error
UpdatePrimaryEmailAddress updates primary email address of a specific user profile this should be called after a prior check of uniqueness is done
func (*ProfileUseCaseImpl) UpdatePrimaryPhoneNumber ¶
func (p *ProfileUseCaseImpl) UpdatePrimaryPhoneNumber( ctx context.Context, phone string, useContext bool, ) error
UpdatePrimaryPhoneNumber updates the primary phone number of a specific user profile this should be called after a prior check of uniqueness is done We use `useContext` to determine which mode to fetch the user profile
func (*ProfileUseCaseImpl) UpdatePushTokens ¶
func (p *ProfileUseCaseImpl) UpdatePushTokens( ctx context.Context, pushToken string, retire bool, ) error
UpdatePushTokens updates primary push tokens of a specific user profile.
func (*ProfileUseCaseImpl) UpdateSecondaryEmailAddresses ¶
func (p *ProfileUseCaseImpl) UpdateSecondaryEmailAddresses( ctx context.Context, emailAddresses []string, ) error
UpdateSecondaryEmailAddresses updates secondary email address of a specific user profile this should be called after a prior check of uniqueness is done
func (*ProfileUseCaseImpl) UpdateSecondaryPhoneNumbers ¶
func (p *ProfileUseCaseImpl) UpdateSecondaryPhoneNumbers( ctx context.Context, phoneNumbers []string, ) error
UpdateSecondaryPhoneNumbers updates secondary phone numbers of a specific user profile this should be called after a prior check of uniqueness is done
func (*ProfileUseCaseImpl) UpdateSuspended ¶
func (p *ProfileUseCaseImpl) UpdateSuspended( ctx context.Context, status bool, phone string, useContext bool, ) error
UpdateSuspended updates primary suspend attribute of a specific user profile
func (*ProfileUseCaseImpl) UpdateUserName ¶
func (p *ProfileUseCaseImpl) UpdateUserName(ctx context.Context, userName string) error
UpdateUserName updates the user username.
func (*ProfileUseCaseImpl) UpdateVerifiedIdentifiers ¶
func (p *ProfileUseCaseImpl) UpdateVerifiedIdentifiers( ctx context.Context, identifiers []profileutils.VerifiedIdentifier, ) error
UpdateVerifiedIdentifiers updates the profile's verified identifiers
func (*ProfileUseCaseImpl) UpdateVerifiedUIDS ¶
func (p *ProfileUseCaseImpl) UpdateVerifiedUIDS(ctx context.Context, uids []string) error
UpdateVerifiedUIDS updates the profile's verified uids
func (*ProfileUseCaseImpl) UserProfile ¶
func (p *ProfileUseCaseImpl) UserProfile(ctx context.Context) (*profileutils.UserProfile, error)
UserProfile retrieves the profile of the logged in user, if they have one
func (*ProfileUseCaseImpl) ValidFCMTokens ¶
func (p *ProfileUseCaseImpl) ValidFCMTokens( ctx context.Context, UIDs []string, ) (map[string][]string, error)
ValidFCMTokens returns valid FCM push tokens for each of the UID in the slice of UIDs provided
type RoleUseCase ¶
type RoleUseCase interface { CreateRole(ctx context.Context, input dto.RoleInput) (*dto.RoleOutput, error) DeleteRole(ctx context.Context, roleID string) (bool, error) GetAllRoles(ctx context.Context) ([]*dto.RoleOutput, error) FindRoleByName(ctx context.Context, roleName *string) ([]*dto.RoleOutput, error) GetAllPermissions(ctx context.Context) ([]*profileutils.Permission, error) GetRoleByName(ctx context.Context, name string) (*dto.RoleOutput, error) // AddPermissionsToRole adds new scopes to a role AddPermissionsToRole( ctx context.Context, input dto.RolePermissionInput, ) (*dto.RoleOutput, error) // RevokeRolePermission removes the specified scopes from a prole RevokeRolePermission( ctx context.Context, input dto.RolePermissionInput, ) (*dto.RoleOutput, error) // UpdateRolePermissions replaces the scopes in a role with new updated scopes UpdateRolePermissions( ctx context.Context, input dto.RolePermissionInput, ) (*dto.RoleOutput, error) // AssignRole assigns a role to a user AssignRole(ctx context.Context, userID string, roleID string) (bool, error) // AssignMultipleRoles assigns multiple roles to a user AssignMultipleRoles(ctx context.Context, userID string, roleIDs []string) (bool, error) // RevokeRole removes a role from a user RevokeRole(ctx context.Context, userID, roleID, reason string) (bool, error) // ActivateRole marks a role as active ActivateRole(ctx context.Context, roleID string) (*dto.RoleOutput, error) // DeactivateRole marks a role as inactive and cannot be used DeactivateRole(ctx context.Context, roleID string) (*dto.RoleOutput, error) // Check permission checks whether a logged in user with the given UID // is authorized to perform the action specified in the permission CheckPermission( ctx context.Context, uid string, permission profileutils.Permission, ) (bool, error) // This usecase is useful for creating the initial role in a new environment // and creating the test role used for running integration and acceptance tests CreateUnauthorizedRole(ctx context.Context, input dto.RoleInput) (*dto.RoleOutput, error) // This usecase is useful for cleaning up and removing the test role(s) used for running integration and acceptance tests UnauthorizedDeleteRole(ctx context.Context, roleID string) (bool, error) GetRolesByIDs(ctx context.Context, roleIDs []string) ([]*dto.RoleOutput, error) }
RoleUseCase represent the business logic required for management of roles
func NewRoleUseCases ¶
func NewRoleUseCases( infrastructure infrastructure.Infrastructure, ext extension.BaseExtension, ) RoleUseCase
NewRoleUseCases returns a new a onboarding usecase
type RoleUseCaseImpl ¶
type RoleUseCaseImpl struct {
// contains filtered or unexported fields
}
RoleUseCaseImpl represents usecase implementation object
func (*RoleUseCaseImpl) ActivateRole ¶ added in v0.0.2
func (r *RoleUseCaseImpl) ActivateRole( ctx context.Context, roleID string, ) (*dto.RoleOutput, error)
ActivateRole marks a deactivated role as active and usable
func (*RoleUseCaseImpl) AddPermissionsToRole ¶
func (r *RoleUseCaseImpl) AddPermissionsToRole( ctx context.Context, input dto.RolePermissionInput, ) (*dto.RoleOutput, error)
AddPermissionsToRole add permission operation to a role
func (RoleUseCaseImpl) AssignMultipleRoles ¶ added in v0.0.2
func (r RoleUseCaseImpl) AssignMultipleRoles(ctx context.Context, userID string, roleIDs []string) (bool, error)
AssignMultipleRoles assigns multiple roles to a user
func (*RoleUseCaseImpl) AssignRole ¶ added in v0.0.2
func (r *RoleUseCaseImpl) AssignRole( ctx context.Context, userID string, roleID string, ) (bool, error)
AssignRole assigns a user a particular role
func (*RoleUseCaseImpl) CheckPermission ¶ added in v0.0.2
func (r *RoleUseCaseImpl) CheckPermission( ctx context.Context, uid string, permission profileutils.Permission, ) (bool, error)
CheckPermission checks whether a logged in user with the given UID is authorized to perform the action specified in the permission
func (*RoleUseCaseImpl) CreateRole ¶
func (r *RoleUseCaseImpl) CreateRole( ctx context.Context, input dto.RoleInput, ) (*dto.RoleOutput, error)
CreateRole creates a new Role
func (*RoleUseCaseImpl) CreateUnauthorizedRole ¶ added in v0.0.2
func (r *RoleUseCaseImpl) CreateUnauthorizedRole( ctx context.Context, input dto.RoleInput, ) (*dto.RoleOutput, error)
CreateUnauthorizedRole creates a role without performing user authorization
This usecase is useful for creating the initial role in a new environment and creating the test role used for running integration and acceptance tests It doesn't check for the users permission
func (*RoleUseCaseImpl) DeactivateRole ¶ added in v0.0.2
func (r *RoleUseCaseImpl) DeactivateRole( ctx context.Context, roleID string, ) (*dto.RoleOutput, error)
DeactivateRole marks a role as inactive and cannot be used
func (*RoleUseCaseImpl) DeleteRole ¶ added in v0.0.2
DeleteRole removes a role from the database permanently
func (*RoleUseCaseImpl) FindRoleByName ¶ added in v0.0.2
func (r *RoleUseCaseImpl) FindRoleByName( ctx context.Context, roleName *string, ) ([]*dto.RoleOutput, error)
FindRoleByName returns a list of roles filtered by name
func (*RoleUseCaseImpl) GetAllPermissions ¶ added in v0.0.2
func (r *RoleUseCaseImpl) GetAllPermissions( ctx context.Context, ) ([]*profileutils.Permission, error)
GetAllPermissions returns a list of all permissions declared in the system
func (*RoleUseCaseImpl) GetAllRoles ¶ added in v0.0.2
func (r *RoleUseCaseImpl) GetAllRoles(ctx context.Context) ([]*dto.RoleOutput, error)
GetAllRoles returns a list of all created roles
func (*RoleUseCaseImpl) GetRoleByName ¶ added in v0.0.2
func (r *RoleUseCaseImpl) GetRoleByName(ctx context.Context, name string) (*dto.RoleOutput, error)
GetRoleByName retrieves a role with the matching name Each role has a unique name i.e no duplicate names
func (RoleUseCaseImpl) GetRolesByIDs ¶ added in v0.0.2
func (r RoleUseCaseImpl) GetRolesByIDs(ctx context.Context, roleIDs []string) ([]*dto.RoleOutput, error)
GetRolesByIDs returns the details of roles given the IDs
func (*RoleUseCaseImpl) RevokeRole ¶ added in v0.0.2
func (r *RoleUseCaseImpl) RevokeRole( ctx context.Context, userID string, roleID string, reason string, ) (bool, error)
RevokeRole removes a role from the user
func (*RoleUseCaseImpl) RevokeRolePermission ¶ added in v0.0.2
func (r *RoleUseCaseImpl) RevokeRolePermission( ctx context.Context, input dto.RolePermissionInput, ) (*dto.RoleOutput, error)
RevokeRolePermission removes a permission from a role
func (*RoleUseCaseImpl) UnauthorizedDeleteRole ¶ added in v0.0.2
UnauthorizedDeleteRole creates a role without performing user authorization
This usecase is useful for cleaning up and removing the test role(s) used for running integration and acceptance tests
func (*RoleUseCaseImpl) UpdateRolePermissions ¶ added in v0.0.2
func (r *RoleUseCaseImpl) UpdateRolePermissions( ctx context.Context, input dto.RolePermissionInput, ) (*dto.RoleOutput, error)
UpdateRolePermissions replaces the scopes in a role with new updated scopes
type SignUpUseCases ¶
type SignUpUseCases interface { // VerifyPhoneNumber checks validity of a phone number by sending an OTP to it VerifyPhoneNumber(ctx context.Context, phone string, appID *string) (*profileutils.OtpResponse, error) // creates an account for the user, setting the provided phone number as the PRIMARY PHONE // NUMBER CreateUserByPhone(ctx context.Context, input *dto.SignUpInput) (*profileutils.UserResponse, error) // updates the user profile of the currently logged in user UpdateUserProfile( ctx context.Context, input *dto.UserProfileInput, ) (*profileutils.UserProfile, error) // adds a new push token in the users profile if the push token does not exist RegisterPushToken(ctx context.Context, token string) (bool, error) CompleteSignup(ctx context.Context, flavour feedlib.Flavour) (bool, error) // removes a push token from the users profile RetirePushToken(ctx context.Context, token string) (bool, error) // fetches the phone numbers of a user for the purposes of recoverying an account. // the returned phone numbers should be masked GetUserRecoveryPhoneNumbers( ctx context.Context, phoneNumber string, ) (*dto.AccountRecoveryPhonesResponse, error) // called to set the provided phone number as the PRIMARY PHONE NUMBER in the user profile of // the user // where the phone number is associated with. SetPhoneAsPrimary(ctx context.Context, phone, otp string) (bool, error) RemoveUserByPhoneNumber(ctx context.Context, phone string) error RegisterUser(ctx context.Context, input dto.RegisterUserInput) (*profileutils.UserProfile, error) }
SignUpUseCases represents all the business logic involved in setting up a user
func NewSignUpUseCases ¶
func NewSignUpUseCases( infrastructure infrastructure.Infrastructure, profile ProfileUseCase, pin UserPINUseCases, ext extension.BaseExtension, ) SignUpUseCases
NewSignUpUseCases returns a new a onboarding usecase
type SignUpUseCasesImpl ¶
type SignUpUseCasesImpl struct {
// contains filtered or unexported fields
}
SignUpUseCasesImpl represents usecase implementation object
func (*SignUpUseCasesImpl) CompleteSignup ¶
func (s *SignUpUseCasesImpl) CompleteSignup( ctx context.Context, flavour feedlib.Flavour, ) (bool, error)
CompleteSignup is not implemented but maintains backward compatibility
This API is only valid for `BEWELL CONSUMER`
func (*SignUpUseCasesImpl) CreateUserByPhone ¶
func (s *SignUpUseCasesImpl) CreateUserByPhone( ctx context.Context, input *dto.SignUpInput, ) (*profileutils.UserResponse, error)
CreateUserByPhone creates an account for the user, setting the provided phone number as the PRIMARY PHONE NUMBER
func (*SignUpUseCasesImpl) GetUserRecoveryPhoneNumbers ¶
func (s *SignUpUseCasesImpl) GetUserRecoveryPhoneNumbers( ctx context.Context, phone string, ) (*dto.AccountRecoveryPhonesResponse, error)
GetUserRecoveryPhoneNumbers fetches the phone numbers of a user for the purposes of recoverying an account.
func (*SignUpUseCasesImpl) RegisterPushToken ¶
RegisterPushToken adds a new push token in the users profile if the push token does not exist
func (*SignUpUseCasesImpl) RegisterUser ¶ added in v0.0.10
func (s *SignUpUseCasesImpl) RegisterUser(ctx context.Context, input dto.RegisterUserInput) (*profileutils.UserProfile, error)
RegisterUser creates a new userprofile
func (*SignUpUseCasesImpl) RemoveUserByPhoneNumber ¶
func (s *SignUpUseCasesImpl) RemoveUserByPhoneNumber(ctx context.Context, phone string) error
RemoveUserByPhoneNumber removes the record of a user using the provided phone number. This method will ONLY be called in testing environment.
func (*SignUpUseCasesImpl) RetirePushToken ¶
RetirePushToken removes a push token from the users profile
func (*SignUpUseCasesImpl) SetPhoneAsPrimary ¶
func (s *SignUpUseCasesImpl) SetPhoneAsPrimary( ctx context.Context, phone, otp string, ) (bool, error)
SetPhoneAsPrimary called to set the provided phone number as the PRIMARY PHONE NUMBER in the user profile of the user where the phone number is associated with.
func (*SignUpUseCasesImpl) UpdateUserProfile ¶
func (s *SignUpUseCasesImpl) UpdateUserProfile( ctx context.Context, input *dto.UserProfileInput, ) (*profileutils.UserProfile, error)
UpdateUserProfile updates the user profile of the currently logged in user
func (*SignUpUseCasesImpl) VerifyPhoneNumber ¶
func (s *SignUpUseCasesImpl) VerifyPhoneNumber( ctx context.Context, phone string, appID *string, ) (*profileutils.OtpResponse, error)
VerifyPhoneNumber checks validity of a phone number by sending an OTP to it
type SurveyUseCases ¶
type SurveyUseCases interface {
RecordPostVisitSurvey(ctx context.Context, input dto.PostVisitSurveyInput) (bool, error)
}
SurveyUseCases represents all the business logic involved in user post visit surveys.
type SurveyUseCasesImpl ¶
type SurveyUseCasesImpl struct {
// contains filtered or unexported fields
}
SurveyUseCasesImpl represents the usecase implementation object
func NewSurveyUseCases ¶
func NewSurveyUseCases( infrastructure infrastructure.Infrastructure, ext extension.BaseExtension, ) *SurveyUseCasesImpl
NewSurveyUseCases initializes a new sign up usecase
func (*SurveyUseCasesImpl) RecordPostVisitSurvey ¶
func (rs *SurveyUseCasesImpl) RecordPostVisitSurvey( ctx context.Context, input dto.PostVisitSurveyInput, ) (bool, error)
RecordPostVisitSurvey records the survey input supplied by the user
type TesterUseCases ¶
type TesterUseCases interface { AddTester(ctx context.Context, email string) (bool, error) RemoveTester(ctx context.Context, email string) (bool, error) ListTesters(ctx context.Context) ([]string, error) }
TesterUseCases represents all the business logic that touch the users that login to test the app
type UserPINUseCases ¶
type UserPINUseCases interface { SetUserPIN(ctx context.Context, pin string, profileID string) (bool, error) // SetUserTempPIN is used to set a temporary PIN for a created user. SetUserTempPIN(ctx context.Context, profileID string) (string, error) ResetUserPIN( ctx context.Context, phone string, PIN string, OTP string, ) (bool, error) ChangeUserPIN(ctx context.Context, phone string, pin string) (bool, error) RequestPINReset(ctx context.Context, phone string, appID *string) (*profileutils.OtpResponse, error) CheckHasPIN(ctx context.Context, profileID string) (bool, error) }
UserPINUseCases represents all the business logic that touch on user PIN Management
func NewUserPinUseCase ¶
func NewUserPinUseCase( infrastructure infrastructure.Infrastructure, p ProfileUseCase, ext extension.BaseExtension, pin extension.PINExtension, ) UserPINUseCases
NewUserPinUseCase returns a new UserPin usecase
type UserPinUseCaseImpl ¶
type UserPinUseCaseImpl struct {
// contains filtered or unexported fields
}
UserPinUseCaseImpl represents usecase implementation object
func (*UserPinUseCaseImpl) ChangeUserPIN ¶
func (u *UserPinUseCaseImpl) ChangeUserPIN( ctx context.Context, phone string, pin string, ) (bool, error)
ChangeUserPIN updates authenticated user's pin with the newly supplied pin
func (*UserPinUseCaseImpl) CheckHasPIN ¶
CheckHasPIN given a phone number checks if the phonenumber is present in our collections which essentially means that the number has an already existing PIN
func (*UserPinUseCaseImpl) RequestPINReset ¶
func (u *UserPinUseCaseImpl) RequestPINReset( ctx context.Context, phone string, appID *string, ) (*profileutils.OtpResponse, error)
RequestPINReset sends a request given an existing user's phone number, sends an otp to the phone number that is then used in the process of updating their old PIN to a new one
func (*UserPinUseCaseImpl) ResetUserPIN ¶
func (u *UserPinUseCaseImpl) ResetUserPIN( ctx context.Context, phone string, PIN string, OTP string, ) (bool, error)
ResetUserPIN resets a user's PIN with the newly supplied PIN
func (*UserPinUseCaseImpl) SetUserPIN ¶
func (u *UserPinUseCaseImpl) SetUserPIN( ctx context.Context, pin string, profileID string, ) (bool, error)
SetUserPIN receives phone number and pin from phonenumber sign up
func (*UserPinUseCaseImpl) SetUserTempPIN ¶
SetUserTempPIN generates a random one time pin. The pin acts as a temporary PIN and should be changed by the user.