diff --git a/docs/spec/components/schemas/EventClaimingState.yaml b/docs/spec/components/schemas/EventClaimingState.yaml index ae8892f..2edd2d9 100644 --- a/docs/spec/components/schemas/EventClaimingState.yaml +++ b/docs/spec/components/schemas/EventClaimingState.yaml @@ -7,9 +7,15 @@ allOf: attributes: required: - claimed + - reward type: object properties: claimed: type: bool example: true - description: If passport scan event was automatically claimed \ No newline at end of file + description: If passport scan event was automatically claimed + reward: + type: integer + format: int64 + description: Reward amount in points + example: 50 \ No newline at end of file diff --git a/internal/service/handlers/fulfill_poll_event.go b/internal/service/handlers/fulfill_poll_event.go index b2bc0f4..3e314a7 100644 --- a/internal/service/handlers/fulfill_poll_event.go +++ b/internal/service/handlers/fulfill_poll_event.go @@ -4,11 +4,12 @@ import ( "encoding/json" "errors" "fmt" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/rarimo/geo-auth-svc/pkg/auth" "math/big" "net/http" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/rarimo/geo-auth-svc/pkg/auth" + validation "github.com/go-ozzo/ozzo-validation/v4" "github.com/rarimo/geo-points-svc/internal/config" "github.com/rarimo/geo-points-svc/internal/data" @@ -127,7 +128,7 @@ func FulfillPollEvent(w http.ResponseWriter, r *http.Request) { if !evType.AutoClaim { log.Debug("Event fulfilled due to disabled auto-claim") - ape.Render(w, newEventClaimingStateResponse(balance.Nullifier, false)) + ape.Render(w, newEventClaimingStateResponse(balance.Nullifier, false, 0)) return } @@ -140,5 +141,5 @@ func FulfillPollEvent(w http.ResponseWriter, r *http.Request) { return } - ape.Render(w, newEventClaimingStateResponse(balance.Nullifier, true)) + ape.Render(w, newEventClaimingStateResponse(balance.Nullifier, true, evType.Reward)) } diff --git a/internal/service/handlers/fulfill_qr_event.go b/internal/service/handlers/fulfill_qr_event.go index 7adc105..d745815 100644 --- a/internal/service/handlers/fulfill_qr_event.go +++ b/internal/service/handlers/fulfill_qr_event.go @@ -73,7 +73,7 @@ func FulfillQREvent(w http.ResponseWriter, r *http.Request) { return } - ape.Render(w, newEventClaimingStateResponse(balance.Nullifier, false)) + ape.Render(w, newEventClaimingStateResponse(balance.Nullifier, false, 0)) return } @@ -88,5 +88,5 @@ func FulfillQREvent(w http.ResponseWriter, r *http.Request) { return } - ape.Render(w, newEventClaimingStateResponse(balance.Nullifier, true)) + ape.Render(w, newEventClaimingStateResponse(balance.Nullifier, true, evType.Reward)) } diff --git a/internal/service/handlers/submit_bonus_code.go b/internal/service/handlers/submit_bonus_code.go index b4a4868..9e7e272 100644 --- a/internal/service/handlers/submit_bonus_code.go +++ b/internal/service/handlers/submit_bonus_code.go @@ -152,5 +152,5 @@ func SubmitBonusCode(w http.ResponseWriter, r *http.Request) { return } - ape.Render(w, newEventClaimingStateResponse(balance.Nullifier, true)) + ape.Render(w, newEventClaimingStateResponse(balance.Nullifier, true, reward)) } diff --git a/internal/service/handlers/verify_external_passport.go b/internal/service/handlers/verify_external_passport.go index 5931e9d..c425dd0 100644 --- a/internal/service/handlers/verify_external_passport.go +++ b/internal/service/handlers/verify_external_passport.go @@ -154,7 +154,7 @@ func VerifyExternalPassport(w http.ResponseWriter, r *http.Request) { return } - ape.Render(w, newEventClaimingStateResponse(req.Data.ID, event != nil)) + ape.Render(w, newEventClaimingStateResponse(req.Data.ID, event != nil, 0)) } diff --git a/internal/service/handlers/verify_internal_passport.go b/internal/service/handlers/verify_internal_passport.go index 3881930..a4c3231 100644 --- a/internal/service/handlers/verify_internal_passport.go +++ b/internal/service/handlers/verify_internal_passport.go @@ -41,7 +41,6 @@ func VerifyInternalPassport(w http.ResponseWriter, r *http.Request) { "balance.nullifier": req.Data.ID, "balance.internal_aid": internalAID, }) - gotSig = r.Header.Get("Signature") ) @@ -145,7 +144,7 @@ func VerifyInternalPassport(w http.ResponseWriter, r *http.Request) { return } - ape.Render(w, newEventClaimingStateResponse(req.Data.ID, false)) + ape.Render(w, newEventClaimingStateResponse(req.Data.ID, false, 0)) return } @@ -198,14 +197,15 @@ func VerifyInternalPassport(w http.ResponseWriter, r *http.Request) { return } - ape.Render(w, newEventClaimingStateResponse(req.Data.ID, event != nil)) + ape.Render(w, newEventClaimingStateResponse(req.Data.ID, event != nil, 0)) } -func newEventClaimingStateResponse(id string, isClaimed bool) resources.EventClaimingStateResponse { +func newEventClaimingStateResponse(id string, isClaimed bool, reward int64) resources.EventClaimingStateResponse { var res resources.EventClaimingStateResponse res.Data.ID = id res.Data.Type = resources.EVENT_CLAIMING_STATE res.Data.Attributes.Claimed = isClaimed + res.Data.Attributes.Reward = reward return res } diff --git a/resources/model_event_claiming_state_attributes.go b/resources/model_event_claiming_state_attributes.go index ac59b3a..4bbab84 100644 --- a/resources/model_event_claiming_state_attributes.go +++ b/resources/model_event_claiming_state_attributes.go @@ -7,4 +7,6 @@ package resources type EventClaimingStateAttributes struct { // If passport scan event was automatically claimed Claimed bool `json:"claimed"` + // Reward amount in points + Reward int64 `json:"reward"` }