usecases

package
Version: v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2021 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const (
	SavannahSladeCode = "1"
	SavannahOrgName   = "Savannah Informatics"

	// PartnerAccountSetupNudgeTitle is the title defined in the `engagement service`
	// for the `PartnerAccountSetupNudge`
	PartnerAccountSetupNudgeTitle = "Setup your partner account"

	// PublishKYCNudgeTitle is the title for the PublishKYCNudge.
	// It takes a partner type as an argument
	PublishKYCNudgeTitle = "Complete your %s KYC"
)

Supplier constants

View Source
const AddNHIFNudgeTitle = "Add NHIF"

AddNHIFNudgeTitle is the title defined in the `engagement service` for the `Add NHIF` nudge

View Source
const (
	// CoverLinkingStatusStarted ...
	CoverLinkingStatusStarted = "coverlinking started"
)
View Source
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 AdminUseCase

type AdminUseCase interface {
	RegisterAdmin(
		ctx context.Context,
		input dto.RegisterAdminInput,
	) (*profileutils.UserProfile, error)
	FetchAdmins(ctx context.Context) ([]*dto.Admin, error)
	ActivateAdmin(ctx context.Context, input dto.ProfileSuspensionInput) (bool, error)
	DeactivateAdmin(ctx context.Context, input dto.ProfileSuspensionInput) (bool, error)
	FindAdminByNameOrPhone(ctx context.Context, nameOrPhone *string) ([]*dto.Admin, error)
}

AdminUseCase represent the business logic required for management of admins

func NewAdminUseCases

NewAdminUseCases returns a new a onboarding usecase

type AdminUseCaseImpl

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

AdminUseCaseImpl represents usecase implementation object

func (*AdminUseCaseImpl) ActivateAdmin added in v0.0.23

func (a *AdminUseCaseImpl) ActivateAdmin(
	ctx context.Context,
	input dto.ProfileSuspensionInput,
) (bool, error)

ActivateAdmin activates/unsuspend the admin profile

func (*AdminUseCaseImpl) DeactivateAdmin added in v0.0.23

func (a *AdminUseCaseImpl) DeactivateAdmin(
	ctx context.Context,
	input dto.ProfileSuspensionInput,
) (bool, error)

DeactivateAdmin deactivates/suspends the admin profile

func (*AdminUseCaseImpl) FetchAdmins

func (a *AdminUseCaseImpl) FetchAdmins(ctx context.Context) ([]*dto.Admin, error)

FetchAdmins fetches registered admins

func (*AdminUseCaseImpl) FindAdminByNameOrPhone added in v0.0.23

func (a *AdminUseCaseImpl) FindAdminByNameOrPhone(
	ctx context.Context,
	nameOrPhone *string,
) ([]*dto.Admin, error)

FindAdminByNameOrPhone is used to find an Admin using their phone number

func (*AdminUseCaseImpl) RegisterAdmin

RegisterAdmin creates a new Admin in bewell

type AgentUseCase

type AgentUseCase interface {
	RegisterAgent(
		ctx context.Context,
		input dto.RegisterAgentInput,
	) (*profileutils.UserProfile, error)
	ActivateAgent(ctx context.Context, input dto.ProfileSuspensionInput) (bool, error)
	DeactivateAgent(ctx context.Context, input dto.ProfileSuspensionInput) (bool, error)
	FetchAgents(ctx context.Context) ([]*dto.Agent, error)
	FindAgentbyPhone(ctx context.Context, phoneNumber *string) (*dto.Agent, error)
}

AgentUseCase represent the business logic required for management of agents

func NewAgentUseCases

NewAgentUseCases returns a new a onboarding usecase

type AgentUseCaseImpl

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

AgentUseCaseImpl represents usecase implementation object

func (*AgentUseCaseImpl) ActivateAgent

func (a *AgentUseCaseImpl) ActivateAgent(
	ctx context.Context,
	input dto.ProfileSuspensionInput,
) (bool, error)

ActivateAgent activates/unsuspend the agent profile

func (*AgentUseCaseImpl) DeactivateAgent

func (a *AgentUseCaseImpl) DeactivateAgent(
	ctx context.Context,
	input dto.ProfileSuspensionInput,
) (bool, error)

DeactivateAgent deactivates/suspends the agent profile

func (*AgentUseCaseImpl) FetchAgents

func (a *AgentUseCaseImpl) FetchAgents(ctx context.Context) ([]*dto.Agent, error)

FetchAgents fetches registered agents

func (*AgentUseCaseImpl) FindAgentbyPhone

func (a *AgentUseCaseImpl) FindAgentbyPhone(
	ctx context.Context,
	phoneNumber *string,
) (*dto.Agent, error)

FindAgentbyPhone is used to find an agent using their phone number

func (*AgentUseCaseImpl) RegisterAgent

RegisterAgent creates a new Agent in bewell

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

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

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

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

func (l *LoginUseCasesImpl) ResumeWithPin(ctx context.Context, pin string) (bool, error)

ResumeWithPin called by the frontend check whether the currently logged in user is the one trying to get access to app

type NHIFUseCaseImpl

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

NHIFUseCaseImpl represents the usecase implementation object

func NewNHIFUseCases

NewNHIFUseCases initializes a new NHIF usecase

func (NHIFUseCaseImpl) AddNHIFDetails

func (n NHIFUseCaseImpl) AddNHIFDetails(
	ctx context.Context,
	input dto.NHIFDetailsInput,
) (*domain.NHIFDetails, error)

AddNHIFDetails adds NHIF details of a user

func (NHIFUseCaseImpl) NHIFDetails

func (n NHIFUseCaseImpl) NHIFDetails(
	ctx context.Context,
) (*domain.NHIFDetails, error)

NHIFDetails returns NHIF details of a user

type NHIFUseCases

type NHIFUseCases interface {
	AddNHIFDetails(
		ctx context.Context,
		input dto.NHIFDetailsInput,
	) (*domain.NHIFDetails, error)
	NHIFDetails(ctx context.Context) (*domain.NHIFDetails, error)
}

NHIFUseCases represents all the business logic involved in NHIF

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
	UpdateCovers(ctx context.Context, covers []profileutils.Cover) 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)

	// 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)

	GetNavigationActions(ctx context.Context) (*dto.GroupedNavigationActions, error)

	SaveFavoriteNavActions(ctx context.Context, title string) (bool, error)

	DeleteFavoriteNavActions(ctx context.Context, title string) (bool, error)

	RefreshNavigationActions(ctx context.Context) (*profileutils.NavigationActions, error)

	SwitchUserFlaggedFeatures(ctx context.Context, phoneNumber string) (*dto.OKResp, error)

	FindUserByPhone(ctx context.Context, phoneNumber string) (*profileutils.UserProfile, error)
}

ProfileUseCase represents all the profile business logic

func NewProfileUseCase

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

func (p *ProfileUseCaseImpl) CheckEmailExists(ctx context.Context, email string) (bool, error)

CheckEmailExists checks whether a email has been registered by another user. Checks both primary and secondary emails.

func (*ProfileUseCaseImpl) CheckPhoneExists

func (p *ProfileUseCaseImpl) CheckPhoneExists(ctx context.Context, phone string) (bool, error)

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) GetAddresses

func (p *ProfileUseCaseImpl) GetAddresses(
	ctx context.Context,
) (*domain.UserAddresses, error)

GetAddresses returns a user's home and work addresses

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) UpdateCovers

func (p *ProfileUseCaseImpl) UpdateCovers(ctx context.Context, covers []profileutils.Cover) error

UpdateCovers updates primary covers 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

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)

	// 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
	CreateUnauthorizedRole(ctx context.Context, input dto.RoleInput) (*dto.RoleOutput, error)

	// 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
	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 agents

func NewRoleUseCases

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

func (r *RoleUseCaseImpl) DeleteRole(ctx context.Context, roleID string) (bool, error)

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

func (r *RoleUseCaseImpl) UnauthorizedDeleteRole(ctx context.Context, roleID string) (bool, error)

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 SMSImpl

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

SMSImpl represents usecase implemention object

func (*SMSImpl) CreateSMSData

func (s *SMSImpl) CreateSMSData(ctx context.Context, input *dto.AfricasTalkingMessage) error

CreateSMSData adds SMS data of the message received

type SMSUsecase

type SMSUsecase interface {
	CreateSMSData(ctx context.Context, input *dto.AfricasTalkingMessage) error
}

SMSUsecase represent the logic involved in receiving an SMS

func NewSMSUsecase

NewSMSUsecase returns a new SMS usecase

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)

	// called to create a customer account in the ERP. This API is only valid for `BEWELL CONSUMER`
	// it should be the last call after updating the users bio data. Its should not return an error
	// when it fails due to unreachable errors, rather it should retry
	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) (*dto.RegisteredUserResponse, error)
}

SignUpUseCases represents all the business logic involved in setting up a user

func NewSignUpUseCases

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 called to create a customer account in the ERP. 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

func (s *SignUpUseCasesImpl) RegisterPushToken(ctx context.Context, token string) (bool, error)

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

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

func (s *SignUpUseCasesImpl) RetirePushToken(ctx context.Context, token string) (bool, error)

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 SupplierUseCases

type SupplierUseCases interface {
	AddPartnerType(ctx context.Context, name *string, partnerType *profileutils.PartnerType) (bool, error)

	FindSupplierByID(ctx context.Context, id string) (*profileutils.Supplier, error)

	FindSupplierByUID(ctx context.Context) (*profileutils.Supplier, error)

	SetUpSupplier(ctx context.Context, accountType profileutils.AccountType) (*profileutils.Supplier, error)

	SuspendSupplier(ctx context.Context, suspensionReason *string) (bool, error)

	EDIUserLogin(ctx context.Context, username, password *string) (*profileutils.EDIUserProfile, error)

	CoreEDIUserLogin(ctx context.Context, username, password string) (*profileutils.EDIUserProfile, error)

	FetchSupplierAllowedLocations(ctx context.Context) (*dto.BranchConnection, error)
	CheckSupplierKYCSubmitted(ctx context.Context) (bool, error)

	AddIndividualRiderKyc(
		ctx context.Context,
		input domain.IndividualRider,
	) (*domain.IndividualRider, error)

	AddOrganizationRiderKyc(
		ctx context.Context,
		input domain.OrganizationRider,
	) (*domain.OrganizationRider, error)

	AddIndividualPractitionerKyc(
		ctx context.Context,
		input domain.IndividualPractitioner,
	) (*domain.IndividualPractitioner, error)

	AddOrganizationPractitionerKyc(
		ctx context.Context,
		input domain.OrganizationPractitioner,
	) (*domain.OrganizationPractitioner, error)

	AddOrganizationProviderKyc(
		ctx context.Context,
		input domain.OrganizationProvider,
	) (*domain.OrganizationProvider, error)

	AddIndividualPharmaceuticalKyc(
		ctx context.Context,
		input domain.IndividualPharmaceutical,
	) (*domain.IndividualPharmaceutical, error)

	AddOrganizationPharmaceuticalKyc(
		ctx context.Context,
		input domain.OrganizationPharmaceutical,
	) (*domain.OrganizationPharmaceutical, error)

	AddIndividualCoachKyc(
		ctx context.Context,
		input domain.IndividualCoach,
	) (*domain.IndividualCoach, error)

	AddOrganizationCoachKyc(
		ctx context.Context,
		input domain.OrganizationCoach,
	) (*domain.OrganizationCoach, error)

	AddIndividualNutritionKyc(
		ctx context.Context,
		input domain.IndividualNutrition,
	) (*domain.IndividualNutrition, error)

	AddOrganizationNutritionKyc(
		ctx context.Context,
		input domain.OrganizationNutrition,
	) (*domain.OrganizationNutrition, error)

	FetchKYCProcessingRequests(ctx context.Context) ([]*domain.KYCRequest, error)

	SupplierEDILogin(
		ctx context.Context,
		username string,
		password string,
		sladeCode string,
	) (*dto.SupplierLogin, error)

	SupplierSetDefaultLocation(ctx context.Context, locationID string) (*profileutils.Supplier, error)

	SaveKYCResponseAndNotifyAdmins(ctx context.Context, sup *profileutils.Supplier) error

	SendKYCEmail(ctx context.Context, text, emailaddress string) error

	StageKYCProcessingRequest(ctx context.Context, sup *profileutils.Supplier) error

	ProcessKYCRequest(
		ctx context.Context,
		id string,
		status domain.KYCProcessStatus,
		rejectionReason *string,
	) (bool, error)

	RetireKYCRequest(ctx context.Context) error

	PublishKYCFeedItem(ctx context.Context, uids ...string) error

	CreateCustomerAccount(
		ctx context.Context,
		name string,
		partnerType profileutils.PartnerType,
	) error

	CreateSupplierAccount(
		ctx context.Context,
		name string,
		partnerType profileutils.PartnerType,
	) error
}

SupplierUseCases represent the business logic required for management of suppliers

type SupplierUseCasesImpl

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

SupplierUseCasesImpl represents usecase implementation object

func (*SupplierUseCasesImpl) AddIndividualCoachKyc

func (s *SupplierUseCasesImpl) AddIndividualCoachKyc(
	ctx context.Context,
	input domain.IndividualCoach,
) (*domain.IndividualCoach, error)

AddIndividualCoachKyc adds KYC for an individual coach

func (*SupplierUseCasesImpl) AddIndividualNutritionKyc

func (s *SupplierUseCasesImpl) AddIndividualNutritionKyc(
	ctx context.Context,
	input domain.IndividualNutrition,
) (*domain.IndividualNutrition, error)

AddIndividualNutritionKyc adds KYC for an individual nutritionist

func (*SupplierUseCasesImpl) AddIndividualPharmaceuticalKyc

func (s *SupplierUseCasesImpl) AddIndividualPharmaceuticalKyc(
	ctx context.Context,
	input domain.IndividualPharmaceutical,
) (*domain.IndividualPharmaceutical, error)

AddIndividualPharmaceuticalKyc adds KYC for an individual Pharmaceutical kyc

func (*SupplierUseCasesImpl) AddIndividualPractitionerKyc

func (s *SupplierUseCasesImpl) AddIndividualPractitionerKyc(
	ctx context.Context,
	input domain.IndividualPractitioner,
) (*domain.IndividualPractitioner, error)

AddIndividualPractitionerKyc adds KYC for an individual practitioner

func (*SupplierUseCasesImpl) AddIndividualRiderKyc

func (s *SupplierUseCasesImpl) AddIndividualRiderKyc(
	ctx context.Context,
	input domain.IndividualRider,
) (*domain.IndividualRider, error)

AddIndividualRiderKyc adds KYC for an individual rider

func (*SupplierUseCasesImpl) AddOrganizationCoachKyc

func (s *SupplierUseCasesImpl) AddOrganizationCoachKyc(
	ctx context.Context,
	input domain.OrganizationCoach,
) (*domain.OrganizationCoach, error)

AddOrganizationCoachKyc adds KYC for an organization coach

func (*SupplierUseCasesImpl) AddOrganizationNutritionKyc

func (s *SupplierUseCasesImpl) AddOrganizationNutritionKyc(
	ctx context.Context,
	input domain.OrganizationNutrition,
) (*domain.OrganizationNutrition, error)

AddOrganizationNutritionKyc adds kyc for a nutritionist organisation

func (*SupplierUseCasesImpl) AddOrganizationPharmaceuticalKyc

func (s *SupplierUseCasesImpl) AddOrganizationPharmaceuticalKyc(
	ctx context.Context,
	input domain.OrganizationPharmaceutical,
) (*domain.OrganizationPharmaceutical, error)

AddOrganizationPharmaceuticalKyc adds KYC for a pharmacy organization

func (*SupplierUseCasesImpl) AddOrganizationPractitionerKyc

func (s *SupplierUseCasesImpl) AddOrganizationPractitionerKyc(
	ctx context.Context,
	input domain.OrganizationPractitioner,
) (*domain.OrganizationPractitioner, error)

AddOrganizationPractitionerKyc adds KYC for an organization practitioner

func (*SupplierUseCasesImpl) AddOrganizationProviderKyc

func (s *SupplierUseCasesImpl) AddOrganizationProviderKyc(
	ctx context.Context,
	input domain.OrganizationProvider,
) (*domain.OrganizationProvider, error)

AddOrganizationProviderKyc adds KYC for an organization provider

func (*SupplierUseCasesImpl) AddOrganizationRiderKyc

func (s *SupplierUseCasesImpl) AddOrganizationRiderKyc(
	ctx context.Context,
	input domain.OrganizationRider,
) (*domain.OrganizationRider, error)

AddOrganizationRiderKyc adds KYC for an organization rider

func (SupplierUseCasesImpl) AddPartnerType

func (s SupplierUseCasesImpl) AddPartnerType(
	ctx context.Context,
	name *string,
	partnerType *profileutils.PartnerType,
) (bool, error)

AddPartnerType create the initial supplier record

func (SupplierUseCasesImpl) CheckSupplierKYCSubmitted

func (s SupplierUseCasesImpl) CheckSupplierKYCSubmitted(ctx context.Context) (bool, error)

CheckSupplierKYCSubmitted checks if a supplier has submitted KYC already.

func (SupplierUseCasesImpl) CoreEDIUserLogin

func (s SupplierUseCasesImpl) CoreEDIUserLogin(
	ctx context.Context,
	username, password string,
) (*profileutils.EDIUserProfile, error)

CoreEDIUserLogin used to login a user to EDI (Core Authserver) and return their EDI EDI (Core Authserver) profile

func (SupplierUseCasesImpl) CreateCustomerAccount

func (s SupplierUseCasesImpl) CreateCustomerAccount(
	ctx context.Context,
	name string,
	partnerType profileutils.PartnerType,
) error

CreateCustomerAccount makes an external call to the Slade 360 ERP to create a customer business partner account

func (SupplierUseCasesImpl) CreateSupplierAccount

func (s SupplierUseCasesImpl) CreateSupplierAccount(
	ctx context.Context,
	name string,
	partnerType profileutils.PartnerType,
) error

CreateSupplierAccount makes a call to our own ERP and creates a supplier account based on the provided partnerType

func (SupplierUseCasesImpl) EDIUserLogin

func (s SupplierUseCasesImpl) EDIUserLogin(
	ctx context.Context,
	username, password *string,
) (*profileutils.EDIUserProfile, error)

EDIUserLogin used to login a user to EDI (Portal Authserver) and return their EDI (Portal Authserver) profile

func (*SupplierUseCasesImpl) FetchKYCProcessingRequests

func (s *SupplierUseCasesImpl) FetchKYCProcessingRequests(
	ctx context.Context,
) ([]*domain.KYCRequest, error)

FetchKYCProcessingRequests fetches a list of all unprocessed kyc approval requests

func (*SupplierUseCasesImpl) FetchSupplierAllowedLocations

func (s *SupplierUseCasesImpl) FetchSupplierAllowedLocations(
	ctx context.Context,
) (*dto.BranchConnection, error)

FetchSupplierAllowedLocations retrieves all the locations that the user in context can work on.

func (SupplierUseCasesImpl) FindSupplierByID

func (s SupplierUseCasesImpl) FindSupplierByID(
	ctx context.Context,
	id string,
) (*profileutils.Supplier, error)

FindSupplierByID fetches a supplier by their id

func (SupplierUseCasesImpl) FindSupplierByUID

func (s SupplierUseCasesImpl) FindSupplierByUID(ctx context.Context) (*profileutils.Supplier, error)

FindSupplierByUID fetches a supplier by logged in user uid

func (*SupplierUseCasesImpl) ProcessKYCRequest

func (s *SupplierUseCasesImpl) ProcessKYCRequest(
	ctx context.Context,
	id string,
	status domain.KYCProcessStatus,
	rejectionReason *string,
) (bool, error)

ProcessKYCRequest transitions a kyc request to a given state

func (SupplierUseCasesImpl) PublishKYCFeedItem

func (s SupplierUseCasesImpl) PublishKYCFeedItem(ctx context.Context, uids ...string) error

PublishKYCFeedItem notifies admin users of a KYC approval request

func (*SupplierUseCasesImpl) PublishKYCNudge

func (s *SupplierUseCasesImpl) PublishKYCNudge(
	ctx context.Context,
	uid string,
	partner *profileutils.PartnerType,
	account *profileutils.AccountType,
) error

PublishKYCNudge pushes a KYC nudge to the user feed

func (*SupplierUseCasesImpl) RetireKYCRequest

func (s *SupplierUseCasesImpl) RetireKYCRequest(ctx context.Context) error

RetireKYCRequest retires the KYC process request of a supplier

func (*SupplierUseCasesImpl) SaveKYCResponseAndNotifyAdmins

func (s *SupplierUseCasesImpl) SaveKYCResponseAndNotifyAdmins(
	ctx context.Context,
	sup *profileutils.Supplier,
) error

SaveKYCResponseAndNotifyAdmins saves the kyc information provided by the user and sends a notification to all admins for a pending KYC review request

func (*SupplierUseCasesImpl) SaveProfileNudge

func (s *SupplierUseCasesImpl) SaveProfileNudge(
	ctx context.Context,
	nudge *feedlib.Nudge,
) error

SaveProfileNudge stages nudges published from this service. These nudges will be referenced later to support some specialized use-case. A nudge will be uniquely identified by its id and sequenceNumber

func (*SupplierUseCasesImpl) SendKYCEmail

func (s *SupplierUseCasesImpl) SendKYCEmail(ctx context.Context, text, emailaddress string) error

SendKYCEmail will send a KYC processing request email to the supplier

func (SupplierUseCasesImpl) SetUpSupplier

func (s SupplierUseCasesImpl) SetUpSupplier(
	ctx context.Context,
	accountType profileutils.AccountType,
) (*profileutils.Supplier, error)

SetUpSupplier performs initial account set up during onboarding

func (*SupplierUseCasesImpl) StageKYCProcessingRequest

func (s *SupplierUseCasesImpl) StageKYCProcessingRequest(
	ctx context.Context,
	sup *profileutils.Supplier,
) error

StageKYCProcessingRequest saves kyc processing requests

func (SupplierUseCasesImpl) SupplierEDILogin

func (s SupplierUseCasesImpl) SupplierEDILogin(
	ctx context.Context,
	username string,
	password string,
	sladeCode string,
) (*dto.SupplierLogin, error)

SupplierEDILogin it used to instantiate as call when setting up a supplier's account's who has an affiliation to a provider with the slade ecosystem. The logic is as follows; 1 . login to the relevant edi to assert the user has an account 2 . fetch the branches of the provider given the slade code which we have 3 . update the user's supplier record 4. return the list of branches to the frontend so that a default location can be set

func (SupplierUseCasesImpl) SupplierSetDefaultLocation

func (s SupplierUseCasesImpl) SupplierSetDefaultLocation(
	ctx context.Context,
	locationID string,
) (*profileutils.Supplier, error)

SupplierSetDefaultLocation updates the default location ot the supplier by the given location id

func (SupplierUseCasesImpl) SuspendSupplier

func (s SupplierUseCasesImpl) SuspendSupplier(ctx context.Context, suspensionReason *string) (bool, error)

SuspendSupplier flips the active boolean on the erp partner from true to false

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

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

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

func (u *UserPinUseCaseImpl) CheckHasPIN(ctx context.Context, profileID string) (bool, error)

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

func (u *UserPinUseCaseImpl) SetUserTempPIN(ctx context.Context, profileID string) (string, error)

SetUserTempPIN generates a random one time pin. The pin acts as a temporary PIN and should be changed by the user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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