forked from skewb1k/tg-gateway-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_verification_status.go
37 lines (31 loc) · 1.33 KB
/
check_verification_status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package tggateway
import (
"context"
"fmt"
)
type CheckVerificationStatusParams struct {
// The unique identifier of the verification request whose status you want to check.
RequestId string `json:"request_id"`
// The code entered by the user.
// If provided, the method checks if the code is valid for the relevant request.
Code string `json:"code,omitempty"`
}
// Use this method to check the status of a verification message that was sent previously.
// If the code was generated by Telegram for you, you can also verify the correctness of the code entered by the user using this method.
// Even if you set the code yourself, it is recommended to call this method after the user has successfully entered the code,
// passing the correct code in the code parameter, so that we can track the conversion rate of your verifications.
func (c Client) CheckVerificationStatus(ctx context.Context, params *CheckVerificationStatusParams) (*RequestStatus, error) {
var resp struct {
Ok bool `json:"ok"`
Error *string `json:"error"`
Result *RequestStatus `json:"result"`
}
err := c.makeAPIRequest(ctx, "checkVerificationStatus", params, &resp)
if err != nil {
return nil, err
}
if resp.Error != nil {
return nil, fmt.Errorf("send verification message failed: %w", c.mapErr(*resp.Error))
}
return resp.Result, nil
}