Skip to content

Commit 192020c

Browse files
Merge pull request #36 from rarimo/feat/ver-link-v2-sex
Update verification link v2 with sex field
2 parents 3fddc99 + c04b823 commit 192020c

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

docs/spec/components/schemas/AdvancedVerification.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ allOf:
2727
type: string
2828
example: "UKR"
2929
description: "User citezenship mask"
30+
sex:
31+
type: string
32+
enum:
33+
- "F"
34+
- "M"
35+
- "O"
36+
- ""
37+
example: "F"
38+
description: "User sex"
3039
expiration_lower_bound:
3140
type: boolean
3241
example: true

internal/service/handlers/verification_link_v2.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ func VerificationLinkV2(w http.ResponseWriter, r *http.Request) {
113113
user.TimestampUpperBound = sql.NullTime{Time: time.Unix(*req.Data.Attributes.TimestampUpperBound, 0), Valid: true}
114114
}
115115

116+
if req.Data.Attributes.Sex != nil {
117+
user.Sex = *req.Data.Attributes.Sex
118+
}
119+
116120
dbUser, err := ctx.VerifyUsersQ(r).Upsert(user)
117121
if err != nil {
118122
ctx.Log(r).WithError(err).WithField("user", user).Errorf("failed to upsert user with userID [%s]", user.UserIDHash)

internal/service/requests/verification_link_v2.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ func VerificationLinkV2(r *http.Request) (req resources.AdvancedVerificationRequ
2828
),
2929
"data/attributes/selector": val.Validate(req.Data.Attributes.Selector, val.Required),
3030
// base v1
31-
"data/attributes/age_lower_bound": val.Validate(req.Data.Attributes.AgeLowerBound, val.NilOrNotEmpty),
32-
"data/attributes/citizenship_mask": val.Validate(req.Data.Attributes.CitizenshipMask, val.NilOrNotEmpty),
31+
"data/attributes/age_lower_bound": val.Validate(req.Data.Attributes.AgeLowerBound, val.NilOrNotEmpty),
32+
"data/attributes/citizenship_mask": val.Validate(req.Data.Attributes.CitizenshipMask, val.NilOrNotEmpty),
33+
"data/attributes/sex": val.Validate(req.Data.Attributes.Sex,
34+
val.When(req.Data.Attributes.Sex != nil,
35+
val.In("F", "M", "O", ""))),
3336
"data/attributes/expiration_lower_bound": val.Validate(req.Data.Attributes.ExpirationLowerBound, val.NilOrNotEmpty),
3437
// advanced v2
3538
"data/attributes/identity_counter": val.Validate(req.Data.Attributes.IdentityCounter, val.When(req.Data.Attributes.IdentityCounter != nil, val.Min(0))),

resources/model_advanced_verification_attributes.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ type AdvancedVerificationAttributes struct {
3131
IdentityCounterUpperBound *int32 `json:"identity_counter_upper_bound,omitempty"`
3232
// Selector value
3333
Selector string `json:"selector"`
34+
// User sex
35+
Sex *string `json:"sex,omitempty"`
3436
// Timestamp lower bound
3537
TimestampLowerBound *int64 `json:"timestamp_lower_bound,omitempty"`
3638
// Timestamp upper bound

0 commit comments

Comments
 (0)