-
Notifications
You must be signed in to change notification settings - Fork 8
Feature/add pegin report endpoint #673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
431c6c7
feat: added pegin report endpoint
gsoares85 9a8c20e
feature: suggested improviments
gsoares85 a87cdf2
feat: changed on the repository to fetch multiple quotes
gsoares85 e20e53f
feat: added code improviments
gsoares85 6646e65
feat: added pegout report endpoint
gsoares85 f520c75
Merge pull request #661 from rsksmart/feature/addPegoutReportEndpoint
gsoares85 651d9c3
feat: fixed merge conflicts
gsoares85 218be28
feat: added date parameters to pegin report
gsoares85 f7d7ca4
feat: added date range filter to pegout reports
gsoares85 5b4ed5e
chore: add API documentation
gsoares85 d436ce4
fix: added deprecated on openApi.yml
gsoares85 454e90c
feat: fixed comments pegin
gsoares85 a20a283
feat: fixed comments on pegout
gsoares85 a7fafdf
feat: change the date to stdlib
gsoares85 ec30f3d
feat: added criteria patter
gsoares85 9824c43
feat: added getQuotesByHashAndDate method
gsoares85 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
36 changes: 36 additions & 0 deletions
36
internal/adapters/entrypoints/rest/handlers/get_reports_pegin.go
This file contains hidden or 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,36 @@ | ||
| package handlers | ||
|
|
||
| import ( | ||
| "github.com/rsksmart/liquidity-provider-server/internal/adapters/entrypoints/rest" | ||
| "github.com/rsksmart/liquidity-provider-server/internal/usecases/pegin" | ||
| "github.com/rsksmart/liquidity-provider-server/pkg" | ||
| "net/http" | ||
| ) | ||
|
|
||
| // NewGetReportsPeginHandler | ||
| // @Title Get Pegin Reports | ||
| // @Description Get the last pegins on the API. Included in the management API. | ||
| // @Param PeginReportsRequest body pkg.PeginReportsRequest true "Date range for the report, case not provided will be last 30 days" | ||
Luisfc68 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // @Success 200 pkg.GetPeginReportResponse | ||
| // @Route /reports/pegin [get] | ||
| func NewGetReportsPeginHandler(useCase *pegin.GetPeginReportUseCase) http.HandlerFunc { | ||
| return func(w http.ResponseWriter, req *http.Request) { | ||
| var err error | ||
|
|
||
| peginReport, err := useCase.Run(req.Context()) | ||
| if err != nil { | ||
| jsonErr := rest.NewErrorResponseWithDetails(UnknownErrorMessage, rest.DetailsFromError(err), false) | ||
| rest.JsonErrorResponse(w, http.StatusInternalServerError, jsonErr) | ||
| return | ||
| } | ||
| response := pkg.GetPeginReportResponse{ | ||
| NumberOfQuotes: peginReport.NumberOfQuotes, | ||
| MinimumQuoteValue: peginReport.MinimumQuoteValue.AsBigInt(), | ||
| MaximumQuoteValue: peginReport.MaximumQuoteValue.AsBigInt(), | ||
| AverageQuoteValue: peginReport.AverageQuoteValue.AsBigInt(), | ||
| TotalFeesCollected: peginReport.TotalFeesCollected.AsBigInt(), | ||
| AverageFeePerQuote: peginReport.AverageFeePerQuote.AsBigInt(), | ||
| } | ||
| rest.JsonResponseWithBody(w, http.StatusOK, &response) | ||
| } | ||
| } | ||
35 changes: 35 additions & 0 deletions
35
internal/adapters/entrypoints/rest/handlers/get_reports_pegout.go
Luisfc68 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,35 @@ | ||
| package handlers | ||
|
|
||
| import ( | ||
| "github.com/rsksmart/liquidity-provider-server/internal/adapters/entrypoints/rest" | ||
| "github.com/rsksmart/liquidity-provider-server/internal/usecases/pegout" | ||
| "github.com/rsksmart/liquidity-provider-server/pkg" | ||
| "net/http" | ||
| ) | ||
|
|
||
| // NewGetReportsPegoutHandler | ||
| // @Title Get Pegout Reports | ||
| // @Description Get the last pegouts on the API. Included in the management API. | ||
| // @Success 200 pkg.GetPegoutReportResponse | ||
| // @Route /reports/pegout [get] | ||
| func NewGetReportsPegoutHandler(useCase *pegout.GetPegoutReportUseCase) http.HandlerFunc { | ||
| return func(w http.ResponseWriter, req *http.Request) { | ||
| var err error | ||
|
|
||
| pegoutReport, err := useCase.Run(req.Context()) | ||
| if err != nil { | ||
| jsonErr := rest.NewErrorResponseWithDetails(UnknownErrorMessage, rest.DetailsFromError(err), false) | ||
| rest.JsonErrorResponse(w, http.StatusInternalServerError, jsonErr) | ||
| return | ||
| } | ||
| response := pkg.GetPegoutReportResponse{ | ||
| NumberOfQuotes: pegoutReport.NumberOfQuotes, | ||
| MinimumQuoteValue: pegoutReport.MinimumQuoteValue.AsBigInt(), | ||
| MaximumQuoteValue: pegoutReport.MaximumQuoteValue.AsBigInt(), | ||
| AverageQuoteValue: pegoutReport.AverageQuoteValue.AsBigInt(), | ||
| TotalFeesCollected: pegoutReport.TotalFeesCollected.AsBigInt(), | ||
| AverageFeePerQuote: pegoutReport.AverageFeePerQuote.AsBigInt(), | ||
| } | ||
| rest.JsonResponseWithBody(w, http.StatusOK, &response) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Luisfc68 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.