Skip to content
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

Add maxAttempts param to verify API #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions verify/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Params struct {
Timeout int
TokenLength int
Subject string
MaxAttempts int
}

type verifyRequest struct {
Expand All @@ -51,6 +52,7 @@ type verifyRequest struct {
Timeout int `json:"timeout,omitempty"`
TokenLength int `json:"tokenLength,omitempty"`
Subject string `json:"subject,omitempty"`
MaxAttempts int `json:"maxAttempts,omitempty"`
}

// Create generates a new One-Time-Password for one recipient.
Expand Down Expand Up @@ -129,6 +131,7 @@ func paramsToVerifyRequest(recipient string, params *Params) (*verifyRequest, er
request.Timeout = params.Timeout
request.TokenLength = params.TokenLength
request.Subject = params.Subject
request.MaxAttempts = params.MaxAttempts

return request, nil
}
Expand Down
2 changes: 2 additions & 0 deletions verify/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func TestRequestDataForVerify(t *testing.T) {
Language: "en-gb",
Timeout: 20,
TokenLength: 8,
MaxAttempts: 3,
}

requestData, err := paramsToVerifyRequest("31612345678", verifyParams)
Expand All @@ -122,4 +123,5 @@ func TestRequestDataForVerify(t *testing.T) {
assert.Equal(t, "en-gb", requestData.Language)
assert.Equal(t, 20, requestData.Timeout)
assert.Equal(t, 8, requestData.TokenLength)
assert.Equal(t, 3, requestData.MaxAttempts)
}