/
canTransferOwnershipResult.go
executable file
·51 lines (39 loc) · 1.69 KB
/
canTransferOwnershipResult.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"fmt"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// CanTransferOwnership Checks whether the current session can be used to transfer a chat ownership to another user
func (client *Client) CanTransferOwnership() (tdlib.CanTransferOwnershipResult, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "canTransferOwnership",
})
if err != nil {
return nil, err
}
if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
switch tdlib.CanTransferOwnershipResultEnum(result.Data["@type"].(string)) {
case tdlib.CanTransferOwnershipResultOkType:
var canTransferOwnershipResult tdlib.CanTransferOwnershipResultOk
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
return &canTransferOwnershipResult, err
case tdlib.CanTransferOwnershipResultPasswordNeededType:
var canTransferOwnershipResult tdlib.CanTransferOwnershipResultPasswordNeeded
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
return &canTransferOwnershipResult, err
case tdlib.CanTransferOwnershipResultPasswordTooFreshType:
var canTransferOwnershipResult tdlib.CanTransferOwnershipResultPasswordTooFresh
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
return &canTransferOwnershipResult, err
case tdlib.CanTransferOwnershipResultSessionTooFreshType:
var canTransferOwnershipResult tdlib.CanTransferOwnershipResultSessionTooFresh
err = json.Unmarshal(result.Raw, &canTransferOwnershipResult)
return &canTransferOwnershipResult, err
default:
return nil, fmt.Errorf("Invalid type")
}
}