-
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.
- Loading branch information
1 parent
0893657
commit b9ba860
Showing
12 changed files
with
161 additions
and
65 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
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 |
---|---|---|
@@ -1,40 +1,9 @@ | ||
package cli | ||
package main | ||
|
||
import ( | ||
"log/slog" | ||
|
||
"github.com/danielmesquitta/openfinance/internal/config" | ||
"github.com/danielmesquitta/openfinance/internal/domain/usecase" | ||
"github.com/danielmesquitta/openfinance/internal/pkg/validator" | ||
"github.com/danielmesquitta/openfinance/internal/provider/companyapi/brasilapi" | ||
"github.com/danielmesquitta/openfinance/internal/provider/gpt/openai" | ||
"github.com/danielmesquitta/openfinance/internal/provider/openfinance/meupluggyapi" | ||
"github.com/danielmesquitta/openfinance/internal/provider/sheet/notionapi" | ||
) | ||
import "github.com/danielmesquitta/openfinance/internal/app/cli" | ||
|
||
func main() { | ||
val := validator.NewValidator() | ||
env := config.NewEnv(val) | ||
companyAPIProvider := brasilapi.NewClient() | ||
gptProvider := openai.NewOpenAIClient(env) | ||
sheetProvider := notionapi.NewClient(env) | ||
openFinanceAPIProvider := meupluggyapi.NewClient(env) | ||
|
||
u := usecase.NewSyncAll( | ||
val, | ||
env, | ||
companyAPIProvider, | ||
gptProvider, | ||
sheetProvider, | ||
openFinanceAPIProvider, | ||
) | ||
|
||
err := u.Execute(usecase.SyncAllDTO{}) | ||
if err != nil { | ||
if err := cli.Run(); err != nil { | ||
panic(err) | ||
} | ||
|
||
slog.Info( | ||
"SyncAll executed successfully", | ||
) | ||
} |
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,3 @@ | ||
package main | ||
|
||
//go:generate go run -mod=mod github.com/google/wire/cmd/wire |
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
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
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,17 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/danielmesquitta/openfinance/internal/app" | ||
"github.com/danielmesquitta/openfinance/internal/domain/usecase" | ||
) | ||
|
||
func Run() error { | ||
syncAllUseCase := app.NewSyncAllUseCase() | ||
|
||
err := syncAllUseCase.Execute(usecase.SyncDTO{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
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
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,43 @@ | ||
//go:build wireinject | ||
// +build wireinject | ||
|
||
package app | ||
|
||
import ( | ||
"github.com/danielmesquitta/openfinance/internal/config" | ||
"github.com/danielmesquitta/openfinance/internal/domain/usecase" | ||
"github.com/danielmesquitta/openfinance/internal/pkg/validator" | ||
"github.com/danielmesquitta/openfinance/internal/provider/companyapi" | ||
"github.com/danielmesquitta/openfinance/internal/provider/companyapi/brasilapi" | ||
"github.com/danielmesquitta/openfinance/internal/provider/gpt" | ||
"github.com/danielmesquitta/openfinance/internal/provider/gpt/openai" | ||
"github.com/danielmesquitta/openfinance/internal/provider/openfinance" | ||
"github.com/danielmesquitta/openfinance/internal/provider/openfinance/meupluggyapi" | ||
"github.com/danielmesquitta/openfinance/internal/provider/sheet" | ||
"github.com/danielmesquitta/openfinance/internal/provider/sheet/notionapi" | ||
"github.com/google/wire" | ||
) | ||
|
||
func NewSyncAllUseCase() *usecase.SyncAll { | ||
wire.Build( | ||
validator.NewValidator, | ||
config.NewEnv, | ||
|
||
wire.Bind(new(companyapi.APIProvider), new(*brasilapi.Client)), | ||
brasilapi.NewClient, | ||
|
||
wire.Bind(new(gpt.Provider), new(*openai.OpenAIClient)), | ||
openai.NewOpenAIClient, | ||
|
||
wire.Bind(new(sheet.Provider), new(*notionapi.Client)), | ||
notionapi.NewClient, | ||
|
||
wire.Bind(new(openfinance.APIProvider), new(*meupluggyapi.Client)), | ||
meupluggyapi.NewClient, | ||
|
||
usecase.NewSyncOne, | ||
usecase.NewSyncAll, | ||
) | ||
|
||
return &usecase.SyncAll{} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package gpt | ||
|
||
type GPTProvider interface { | ||
type Provider interface { | ||
CreateChatCompletion(message string) (string, error) | ||
} |
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