-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tentative API endpoint to retrieve a sanction check.
- Loading branch information
Showing
12 changed files
with
214 additions
and
30 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,33 @@ | ||
package api | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/checkmarble/marble-backend/dto" | ||
"github.com/checkmarble/marble-backend/pure_utils" | ||
"github.com/checkmarble/marble-backend/usecases" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func handleListSanctionChecks(uc usecases.Usecases) func(c *gin.Context) { | ||
return func(c *gin.Context) { | ||
ctx := c.Request.Context() | ||
decisionId := c.Query("decision_id") | ||
|
||
if decisionId == "" { | ||
c.Status(http.StatusBadRequest) | ||
return | ||
} | ||
|
||
uc := usecasesWithCreds(ctx, uc).NewSanctionCheckUsecase() | ||
sanctionChecks, err := uc.ListSanctionChecks(ctx, decisionId) | ||
|
||
if presentError(ctx, c, err) { | ||
return | ||
} | ||
|
||
sanctionCheckJson := pure_utils.Map(sanctionChecks, dto.AdaptSanctionCheckDto) | ||
|
||
c.JSON(http.StatusOK, sanctionCheckJson) | ||
} | ||
} |
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,57 @@ | ||
package dto | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/checkmarble/marble-backend/models" | ||
"github.com/checkmarble/marble-backend/pure_utils" | ||
) | ||
|
||
type SanctionCheckDto struct { | ||
Id string `json:"id"` | ||
Partial bool `json:"partial"` | ||
Datasets []string `json:"datasets"` | ||
Count int `json:"count"` | ||
Request json.RawMessage `json:"request"` | ||
Matches []SanctionCheckMatchDto `json:"matches"` | ||
} | ||
|
||
func AdaptSanctionCheckDto(m models.SanctionCheckExecution) SanctionCheckDto { | ||
sanctionCheck := SanctionCheckDto{ | ||
Id: m.Id, | ||
Partial: m.Partial, | ||
Count: m.Count, | ||
Datasets: make([]string, 0), | ||
Request: m.Query.QueryPayload, | ||
Matches: make([]SanctionCheckMatchDto, 0), | ||
} | ||
|
||
if len(m.Query.OrgConfig.Datasets) > 0 { | ||
sanctionCheck.Datasets = m.Query.OrgConfig.Datasets | ||
} | ||
if len(m.Matches) > 0 { | ||
sanctionCheck.Matches = pure_utils.Map(m.Matches, AdaptSanctionCheckMatchDto) | ||
} | ||
|
||
return sanctionCheck | ||
} | ||
|
||
type SanctionCheckMatchDto struct { | ||
Id string `json:"id"` | ||
EntityId string `json:"entity_id"` | ||
QueryIds []string `json:"query_ids"` | ||
Datasets []string `json:"datasets"` | ||
Payload json.RawMessage `json:"payload"` | ||
} | ||
|
||
func AdaptSanctionCheckMatchDto(m models.SanctionCheckExecutionMatch) SanctionCheckMatchDto { | ||
match := SanctionCheckMatchDto{ | ||
Id: m.Id, | ||
EntityId: m.EntityId, | ||
QueryIds: m.QueryIds, | ||
Datasets: make([]string, 0), | ||
Payload: m.Payload, | ||
} | ||
|
||
return match | ||
} |
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
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
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
Oops, something went wrong.