Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
Better context handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lornajane committed Nov 6, 2020
1 parent 468f06b commit 5e378b9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions verify.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package vonage

import (
"context"
"encoding/json"
"io/ioutil"

Expand Down Expand Up @@ -74,7 +75,8 @@ func (client *VerifyClient) Request(number string, brand string, opts VerifyOpts
verifyOpts.SenderId = optional.NewString(opts.SenderID)
}

result, resp, err := verifyClient.DefaultApi.VerifyRequest(nil, "json", client.apiKey, client.apiSecret, number, brand, &verifyOpts)
ctx := context.Background()
result, resp, err := verifyClient.DefaultApi.VerifyRequest(ctx, "json", client.apiKey, client.apiSecret, number, brand, &verifyOpts)

// catch HTTP errors
if err != nil {
Expand Down Expand Up @@ -110,7 +112,8 @@ func (client *VerifyClient) Check(requestID string, code string) (VerifyCheckRes

// set up and then parse the options
verifyOpts := verify.VerifyCheckOpts{}
result, resp, err := verifyClient.DefaultApi.VerifyCheck(nil, "json", client.apiKey, client.apiSecret, requestID, code, &verifyOpts)
ctx := context.Background()
result, resp, err := verifyClient.DefaultApi.VerifyCheck(ctx, "json", client.apiKey, client.apiSecret, requestID, code, &verifyOpts)

// catch HTTP errors
if err != nil {
Expand Down Expand Up @@ -156,7 +159,8 @@ func (client *VerifyClient) Search(requestID string) (VerifySearchResponse, Veri
// set up and then parse the options
verifyOpts := verify.VerifySearchOpts{}
verifyOpts.RequestId = optional.NewString(requestID)
result, resp, err := verifyClient.DefaultApi.VerifySearch(nil, "json", client.apiKey, client.apiSecret, &verifyOpts)
ctx := context.Background()
result, resp, err := verifyClient.DefaultApi.VerifySearch(ctx, "json", client.apiKey, client.apiSecret, &verifyOpts)

// catch HTTP errors
if err != nil {
Expand Down Expand Up @@ -187,7 +191,8 @@ func (client *VerifyClient) Cancel(requestID string) (VerifyControlResponse, Ver
// create the client
verifyClient := verify.NewAPIClient(client.Config)

result, resp, err := verifyClient.DefaultApi.VerifyControl(nil, "json", client.apiKey, client.apiSecret, requestID, "cancel")
ctx := context.Background()
result, resp, err := verifyClient.DefaultApi.VerifyControl(ctx, "json", client.apiKey, client.apiSecret, requestID, "cancel")

// catch HTTP errors
if err != nil {
Expand All @@ -213,7 +218,8 @@ func (client *VerifyClient) TriggerNextEvent(requestID string) (VerifyControlRes
// create the client
verifyClient := verify.NewAPIClient(client.Config)

result, resp, err := verifyClient.DefaultApi.VerifyControl(nil, "json", client.apiKey, client.apiSecret, requestID, "trigger_next_event")
ctx := context.Background()
result, resp, err := verifyClient.DefaultApi.VerifyControl(ctx, "json", client.apiKey, client.apiSecret, requestID, "trigger_next_event")

// catch HTTP errors
if err != nil {
Expand Down Expand Up @@ -264,7 +270,8 @@ func (client *VerifyClient) Psd2(number string, payee string, amount float64, op
verifyOpts.WorkflowId = optional.NewInt32(opts.WorkflowID)
}

result, resp, err := verifyClient.DefaultApi.VerifyRequestWithPSD2(nil, "json", client.apiKey, client.apiSecret, number, payee, float32(amount), &verifyOpts)
ctx := context.Background()
result, resp, err := verifyClient.DefaultApi.VerifyRequestWithPSD2(ctx, "json", client.apiKey, client.apiSecret, number, payee, float32(amount), &verifyOpts)

// catch HTTP errors
if err != nil {
Expand Down

0 comments on commit 5e378b9

Please sign in to comment.