refactor: move the driver interfaces to the service layer

This commit is contained in:
Ruidy 2025-01-15 22:24:42 +01:00
parent 49c49f4098
commit cb6677ca60
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
3 changed files with 12 additions and 14 deletions

View file

@ -16,10 +16,6 @@ import (
"google.golang.org/api/option"
)
type Client interface {
Create(calendarId, name, description string, from, to time.Time) error
}
type GoogleClient struct {
calIds map[string]struct{}
*calendar.Service

View file

@ -11,11 +11,6 @@ import (
"github.com/labstack/gommon/log"
)
type Client interface {
BuildInvoice(context map[string]any) error
BuildReport(context map[string]any, period string, month, year int) error
}
type PdfClient struct {
path string
invoiceId string

View file

@ -5,8 +5,6 @@ import (
"time"
"github.com/rjNemo/rentease/internal/config"
"github.com/rjNemo/rentease/internal/driver/calendar"
"github.com/rjNemo/rentease/internal/driver/pdf"
)
type Store interface {
@ -26,6 +24,15 @@ type Store interface {
UpdateItem(id int, item string, paymentMethod string, paymentStatus string, qty int, price float64) (*Item, error)
}
type PdfClient interface {
BuildInvoice(context map[string]any) error
BuildReport(context map[string]any, period string, month, year int) error
}
type CalendarClient interface {
Create(calendarId, name, description string, from, to time.Time) error
}
type parserClient interface {
Parse(rawContent string) (*Booking, error)
}
@ -33,11 +40,11 @@ type parserClient interface {
type Service struct {
store Store
parser parserClient
calendar calendar.Client
pdf pdf.Client
calendar CalendarClient
pdf PdfClient
}
func NewService(store Store, parser parserClient, calendar calendar.Client, pdf pdf.Client) (*Service, error) {
func NewService(store Store, parser parserClient, calendar CalendarClient, pdf PdfClient) (*Service, error) {
return &Service{
store: store,
parser: parser,