Skip to content

Commit

Permalink
chore: scaffold client and user usecases (#33)
Browse files Browse the repository at this point in the history
Signed-off-by: Otieno Calvine <nyarangaotieno@gmail.com>
  • Loading branch information
NYARAS committed Oct 15, 2021
1 parent b776b48 commit 2a6ab85
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 5 deletions.
78 changes: 73 additions & 5 deletions pkg/onboarding/usecases/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,82 @@ type UseCasesClientProfile interface {
IAddRelatedPerson
}

// UseCasesClientProfileImpl represents user implementation object
type UseCasesClientProfileImpl struct {
// UseCasesClientImpl represents user implementation object
type UseCasesClientImpl struct {
Infrastructure infrastructure.Interactor
}

// NewUseCasesClientProfileImpl returns a new client profile service
func NewUseCasesClientProfileImpl(infra infrastructure.Interactor) *UseCasesClientProfileImpl {
return &UseCasesClientProfileImpl{
// NewUseCasesClientImpl returns a new Client service
func NewUseCasesClientImpl(infra infrastructure.Interactor) *UseCasesClientImpl {
return &UseCasesClientImpl{
Infrastructure: infra,
}
}

// RegisterClient registers a client into the platform
func (cl *UseCasesClientImpl) RegisterClient(user domain.User, profile domain.ClientProfileRegistrationPayload) (*domain.ClientProfile, error) {
return nil, nil
}

// AddIdentifier stages and adds client identifiers
func (cl *UseCasesClientImpl) AddIdentifier(clientID string, idType string, idValue string, isPrimary bool) (*domain.Identifier, error) {
return nil, nil
}

// InactivateClient makes a client inactive and removes the client from the list of active users
func (cl *UseCasesClientImpl) InactivateClient(clientID string, reason string, notes string) (bool, error) {
return true, nil
}

// ReactivateClient makes inactive client active and returns the client to the list of active user
func (cl *UseCasesClientImpl) ReactivateClient(clientID string, reason string, notes string) (bool, error) {
return true, nil
}

// TransferClient transfer a client from one facility to another facility
func (cl *UseCasesClientImpl) TransferClient(
clientID string,
OriginFacilityID string,
DestinationFacilityID string,
Reason string, // TODO: consider making this an enum
Notes string, // optional notes...e.g if the reason given is "Other"
) (bool, error) {
return true, nil
}

// GetIdentifiers fetches and returns a list of client active identifiers
func (cl *UseCasesClientImpl) GetIdentifiers(clientID string, active bool) ([]*domain.Identifier, error) {
return nil, nil
}

// InactivateIdentifier toggles and make client identifier inactive
func (cl *UseCasesClientImpl) InactivateIdentifier(clientID string, identifierID string) (bool, error) {
return true, nil
}

// AssignTreatmentSupporter assigns a treatment supporter to a client
func (cl *UseCasesClientImpl) AssignTreatmentSupporter(
clientID string,
treatmentSupporterID string,
treatmentSupporterType string, // TODO: enum, start with CHV and Treatment buddy
) (bool, error) {
return true, nil
}

// UnassignTreatmentSupporter unassign treatment supporter from a client
func (cl *UseCasesClientImpl) UnassignTreatmentSupporter(
clientID string,
treatmentSupporterID string,
reason string, // TODO: ensure these are in an audit log
notes string, // TODO: Optional
) (bool, error) {
return true, nil
}

// AddRelatedPerson adds client related person. The related person here is like Next of Kin
func (cl *UseCasesClientImpl) AddRelatedPerson(
clientID string,
relatedPerson *domain.RelatedPerson,
) (*domain.RelatedPerson, bool) {
return nil, false
}
8 changes: 8 additions & 0 deletions pkg/onboarding/usecases/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package usecases

import (
"github.com/savannahghi/onboarding-service/pkg/onboarding/infrastructure"
"github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/client"
"github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/facility"
"github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/metric"
"github.com/savannahghi/onboarding-service/pkg/onboarding/usecases/user"
engagementSvc "github.com/savannahghi/onboarding/pkg/onboarding/infrastructure/services/engagement"
)

Expand All @@ -12,17 +14,23 @@ type Interactor struct {
*engagementSvc.ServiceEngagementImpl
*facility.UseCaseFacilityImpl
*metric.UsecaseMetricsImpl
*user.UseCasesUserImpl
*client.UseCasesClientImpl
}

// NewUsecasesInteractor initializes a new usecases interactor
func NewUsecasesInteractor(infrastructure infrastructure.Interactor) Interactor {
var engagement *engagementSvc.ServiceEngagementImpl
facility := facility.NewFacilityUsecase(infrastructure)
metrics := metric.NewMetricUsecase(infrastructure)
user := user.NewUseCasesUserImpl(infrastructure)
client := client.NewUseCasesClientImpl(infrastructure)

return Interactor{
engagement,
facility,
metrics,
user,
client,
}
}
50 changes: 50 additions & 0 deletions pkg/onboarding/usecases/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,53 @@ func NewUseCasesUserImpl(infra infrastructure.Interactor) *UseCasesUserImpl {
Infrastructure: infra,
}
}

// Login is used to login the user into the application
func (us *UseCasesUserImpl) Login(userID string, pin string, flavour string) (*domain.AuthCredentials, string, error) {
return nil, "", nil
}

// ResetPIN resets user PIN
func (us *UseCasesUserImpl) ResetPIN(userID string, flavour string) (bool, error) {
return true, nil
}

// VerifyPIN verifies user PIN
func (us *UseCasesUserImpl) VerifyPIN(userID string, flavour string, pin string) (bool, error) {
return true, nil
}

// ReviewTerms is used to accept or review terms
func (us *UseCasesUserImpl) ReviewTerms(userID string, accepted bool, flavour string) (bool, error) {
return true, nil
}

// GetAnonymizedUserIdentifier is used to get an opaque (but **stable**) user
//
// identifier for events, analytics etc
func (us *UseCasesUserImpl) GetAnonymizedUserIdentifier(userID string, flavour string) (string, error) {
return "", nil
}

// AddPushtoken adds push token to a user
func (us *UseCasesUserImpl) AddPushtoken(userID string, flavour string) (bool, error) {
return true, nil
}

// RemovePushToken removes/retires user push token
func (us *UseCasesUserImpl) RemovePushToken(userID string, flavour string) (bool, error) {
return true, nil
}

// UpdateLanguagePreferences updates user language preferences
func (us *UseCasesUserImpl) UpdateLanguagePreferences(userID string, language string) (bool, error) {
return true, nil
}

// Invite is sends an invite to a user (client/staff)
// The invite contains: link to app/play store, temporary PIN that **MUST** be changed on first login
//
// The default invite channel is SMS
func (us *UseCasesUserImpl) Invite(userID string, flavour string) (bool, error) {
return false, nil
}

0 comments on commit 2a6ab85

Please sign in to comment.