-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor library to use usecases
- Loading branch information
1 parent
3195cee
commit b6525ec
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package library | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/savannahghi/engagementcore/pkg/engagement/domain" | ||
"github.com/savannahghi/engagementcore/pkg/engagement/infrastructure" | ||
"github.com/savannahghi/feedlib" | ||
) | ||
|
||
// UsecaseLibrary defines Libray service usecases interface | ||
type UsecaseLibrary interface { | ||
GetFeedContent( | ||
ctx context.Context, | ||
flavour feedlib.Flavour, | ||
) ([]*domain.GhostCMSPost, error) | ||
GetFaqsContent( | ||
ctx context.Context, | ||
flavour feedlib.Flavour, | ||
) ([]*domain.GhostCMSPost, error) | ||
GetLibraryContent( | ||
ctx context.Context, | ||
) ([]*domain.GhostCMSPost, error) | ||
} | ||
|
||
// ImplLibrary is the library service implementation | ||
type ImplLibrary struct { | ||
infrastructure infrastructure.Interactor | ||
} | ||
|
||
// NewLibrary initializes a Library service instance | ||
func NewLibrary(infrastructure infrastructure.Interactor) *ImplLibrary { | ||
return &ImplLibrary{ | ||
infrastructure: infrastructure, | ||
} | ||
} | ||
|
||
// GetFeedContent gets feed content from ghost cms | ||
func (l *ImplLibrary) GetFeedContent( | ||
ctx context.Context, | ||
flavour feedlib.Flavour, | ||
) ([]*domain.GhostCMSPost, error) { | ||
i := l.infrastructure.ServiceLibraryImpl | ||
return i.GetFeedContent(ctx, flavour) | ||
} | ||
|
||
// GetFaqsContent gets FAQ content from ghost cms | ||
func (l *ImplLibrary) GetFaqsContent( | ||
ctx context.Context, | ||
flavour feedlib.Flavour, | ||
) ([]*domain.GhostCMSPost, error) { | ||
i := l.infrastructure.ServiceLibraryImpl | ||
return i.GetFaqsContent(ctx, flavour) | ||
|
||
} | ||
|
||
// GetLibraryContent gets Library content from ghost cms | ||
func (l *ImplLibrary) GetLibraryContent( | ||
ctx context.Context, | ||
) ([]*domain.GhostCMSPost, error) { | ||
i := l.infrastructure.ServiceLibraryImpl | ||
return i.GetLibraryContent(ctx) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters