github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/phone_numbers.go (about) 1 // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler) 2 // Input file: avdl/keybase1/phone_numbers.avdl 3 4 package keybase1 5 6 import ( 7 "github.com/keybase/go-framed-msgpack-rpc/rpc" 8 context "golang.org/x/net/context" 9 "time" 10 ) 11 12 // Phone number support for TOFU chats. 13 type UserPhoneNumber struct { 14 PhoneNumber PhoneNumber `codec:"phoneNumber" json:"phone_number"` 15 Verified bool `codec:"verified" json:"verified"` 16 Superseded bool `codec:"superseded" json:"superseded"` 17 Visibility IdentityVisibility `codec:"visibility" json:"visibility"` 18 Ctime UnixTime `codec:"ctime" json:"ctime"` 19 } 20 21 func (o UserPhoneNumber) DeepCopy() UserPhoneNumber { 22 return UserPhoneNumber{ 23 PhoneNumber: o.PhoneNumber.DeepCopy(), 24 Verified: o.Verified, 25 Superseded: o.Superseded, 26 Visibility: o.Visibility.DeepCopy(), 27 Ctime: o.Ctime.DeepCopy(), 28 } 29 } 30 31 type PhoneNumberLookupResult struct { 32 PhoneNumber RawPhoneNumber `codec:"phoneNumber" json:"phone_number"` 33 CoercedPhoneNumber PhoneNumber `codec:"coercedPhoneNumber" json:"coerced_phone_number"` 34 Err *string `codec:"err,omitempty" json:"err,omitempty"` 35 Uid *UID `codec:"uid,omitempty" json:"uid,omitempty"` 36 } 37 38 func (o PhoneNumberLookupResult) DeepCopy() PhoneNumberLookupResult { 39 return PhoneNumberLookupResult{ 40 PhoneNumber: o.PhoneNumber.DeepCopy(), 41 CoercedPhoneNumber: o.CoercedPhoneNumber.DeepCopy(), 42 Err: (func(x *string) *string { 43 if x == nil { 44 return nil 45 } 46 tmp := (*x) 47 return &tmp 48 })(o.Err), 49 Uid: (func(x *UID) *UID { 50 if x == nil { 51 return nil 52 } 53 tmp := (*x).DeepCopy() 54 return &tmp 55 })(o.Uid), 56 } 57 } 58 59 type PhoneNumberChangedMsg struct { 60 PhoneNumber PhoneNumber `codec:"phoneNumber" json:"phone"` 61 } 62 63 func (o PhoneNumberChangedMsg) DeepCopy() PhoneNumberChangedMsg { 64 return PhoneNumberChangedMsg{ 65 PhoneNumber: o.PhoneNumber.DeepCopy(), 66 } 67 } 68 69 type AddPhoneNumberArg struct { 70 SessionID int `codec:"sessionID" json:"sessionID"` 71 PhoneNumber PhoneNumber `codec:"phoneNumber" json:"phoneNumber"` 72 Visibility IdentityVisibility `codec:"visibility" json:"visibility"` 73 } 74 75 type EditPhoneNumberArg struct { 76 SessionID int `codec:"sessionID" json:"sessionID"` 77 OldPhoneNumber PhoneNumber `codec:"oldPhoneNumber" json:"oldPhoneNumber"` 78 PhoneNumber PhoneNumber `codec:"phoneNumber" json:"phoneNumber"` 79 Visibility IdentityVisibility `codec:"visibility" json:"visibility"` 80 } 81 82 type VerifyPhoneNumberArg struct { 83 SessionID int `codec:"sessionID" json:"sessionID"` 84 PhoneNumber PhoneNumber `codec:"phoneNumber" json:"phoneNumber"` 85 Code string `codec:"code" json:"code"` 86 } 87 88 type ResendVerificationForPhoneNumberArg struct { 89 SessionID int `codec:"sessionID" json:"sessionID"` 90 PhoneNumber PhoneNumber `codec:"phoneNumber" json:"phoneNumber"` 91 } 92 93 type GetPhoneNumbersArg struct { 94 SessionID int `codec:"sessionID" json:"sessionID"` 95 } 96 97 type DeletePhoneNumberArg struct { 98 SessionID int `codec:"sessionID" json:"sessionID"` 99 PhoneNumber PhoneNumber `codec:"phoneNumber" json:"phoneNumber"` 100 } 101 102 type SetVisibilityPhoneNumberArg struct { 103 SessionID int `codec:"sessionID" json:"sessionID"` 104 PhoneNumber PhoneNumber `codec:"phoneNumber" json:"phoneNumber"` 105 Visibility IdentityVisibility `codec:"visibility" json:"visibility"` 106 } 107 108 type SetVisibilityAllPhoneNumberArg struct { 109 SessionID int `codec:"sessionID" json:"sessionID"` 110 Visibility IdentityVisibility `codec:"visibility" json:"visibility"` 111 } 112 113 type PhoneNumbersInterface interface { 114 AddPhoneNumber(context.Context, AddPhoneNumberArg) error 115 EditPhoneNumber(context.Context, EditPhoneNumberArg) error 116 VerifyPhoneNumber(context.Context, VerifyPhoneNumberArg) error 117 ResendVerificationForPhoneNumber(context.Context, ResendVerificationForPhoneNumberArg) error 118 GetPhoneNumbers(context.Context, int) ([]UserPhoneNumber, error) 119 DeletePhoneNumber(context.Context, DeletePhoneNumberArg) error 120 SetVisibilityPhoneNumber(context.Context, SetVisibilityPhoneNumberArg) error 121 SetVisibilityAllPhoneNumber(context.Context, SetVisibilityAllPhoneNumberArg) error 122 } 123 124 func PhoneNumbersProtocol(i PhoneNumbersInterface) rpc.Protocol { 125 return rpc.Protocol{ 126 Name: "keybase.1.phoneNumbers", 127 Methods: map[string]rpc.ServeHandlerDescription{ 128 "addPhoneNumber": { 129 MakeArg: func() interface{} { 130 var ret [1]AddPhoneNumberArg 131 return &ret 132 }, 133 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 134 typedArgs, ok := args.(*[1]AddPhoneNumberArg) 135 if !ok { 136 err = rpc.NewTypeError((*[1]AddPhoneNumberArg)(nil), args) 137 return 138 } 139 err = i.AddPhoneNumber(ctx, typedArgs[0]) 140 return 141 }, 142 }, 143 "editPhoneNumber": { 144 MakeArg: func() interface{} { 145 var ret [1]EditPhoneNumberArg 146 return &ret 147 }, 148 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 149 typedArgs, ok := args.(*[1]EditPhoneNumberArg) 150 if !ok { 151 err = rpc.NewTypeError((*[1]EditPhoneNumberArg)(nil), args) 152 return 153 } 154 err = i.EditPhoneNumber(ctx, typedArgs[0]) 155 return 156 }, 157 }, 158 "verifyPhoneNumber": { 159 MakeArg: func() interface{} { 160 var ret [1]VerifyPhoneNumberArg 161 return &ret 162 }, 163 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 164 typedArgs, ok := args.(*[1]VerifyPhoneNumberArg) 165 if !ok { 166 err = rpc.NewTypeError((*[1]VerifyPhoneNumberArg)(nil), args) 167 return 168 } 169 err = i.VerifyPhoneNumber(ctx, typedArgs[0]) 170 return 171 }, 172 }, 173 "resendVerificationForPhoneNumber": { 174 MakeArg: func() interface{} { 175 var ret [1]ResendVerificationForPhoneNumberArg 176 return &ret 177 }, 178 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 179 typedArgs, ok := args.(*[1]ResendVerificationForPhoneNumberArg) 180 if !ok { 181 err = rpc.NewTypeError((*[1]ResendVerificationForPhoneNumberArg)(nil), args) 182 return 183 } 184 err = i.ResendVerificationForPhoneNumber(ctx, typedArgs[0]) 185 return 186 }, 187 }, 188 "getPhoneNumbers": { 189 MakeArg: func() interface{} { 190 var ret [1]GetPhoneNumbersArg 191 return &ret 192 }, 193 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 194 typedArgs, ok := args.(*[1]GetPhoneNumbersArg) 195 if !ok { 196 err = rpc.NewTypeError((*[1]GetPhoneNumbersArg)(nil), args) 197 return 198 } 199 ret, err = i.GetPhoneNumbers(ctx, typedArgs[0].SessionID) 200 return 201 }, 202 }, 203 "deletePhoneNumber": { 204 MakeArg: func() interface{} { 205 var ret [1]DeletePhoneNumberArg 206 return &ret 207 }, 208 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 209 typedArgs, ok := args.(*[1]DeletePhoneNumberArg) 210 if !ok { 211 err = rpc.NewTypeError((*[1]DeletePhoneNumberArg)(nil), args) 212 return 213 } 214 err = i.DeletePhoneNumber(ctx, typedArgs[0]) 215 return 216 }, 217 }, 218 "setVisibilityPhoneNumber": { 219 MakeArg: func() interface{} { 220 var ret [1]SetVisibilityPhoneNumberArg 221 return &ret 222 }, 223 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 224 typedArgs, ok := args.(*[1]SetVisibilityPhoneNumberArg) 225 if !ok { 226 err = rpc.NewTypeError((*[1]SetVisibilityPhoneNumberArg)(nil), args) 227 return 228 } 229 err = i.SetVisibilityPhoneNumber(ctx, typedArgs[0]) 230 return 231 }, 232 }, 233 "setVisibilityAllPhoneNumber": { 234 MakeArg: func() interface{} { 235 var ret [1]SetVisibilityAllPhoneNumberArg 236 return &ret 237 }, 238 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 239 typedArgs, ok := args.(*[1]SetVisibilityAllPhoneNumberArg) 240 if !ok { 241 err = rpc.NewTypeError((*[1]SetVisibilityAllPhoneNumberArg)(nil), args) 242 return 243 } 244 err = i.SetVisibilityAllPhoneNumber(ctx, typedArgs[0]) 245 return 246 }, 247 }, 248 }, 249 } 250 } 251 252 type PhoneNumbersClient struct { 253 Cli rpc.GenericClient 254 } 255 256 func (c PhoneNumbersClient) AddPhoneNumber(ctx context.Context, __arg AddPhoneNumberArg) (err error) { 257 err = c.Cli.Call(ctx, "keybase.1.phoneNumbers.addPhoneNumber", []interface{}{__arg}, nil, 0*time.Millisecond) 258 return 259 } 260 261 func (c PhoneNumbersClient) EditPhoneNumber(ctx context.Context, __arg EditPhoneNumberArg) (err error) { 262 err = c.Cli.Call(ctx, "keybase.1.phoneNumbers.editPhoneNumber", []interface{}{__arg}, nil, 0*time.Millisecond) 263 return 264 } 265 266 func (c PhoneNumbersClient) VerifyPhoneNumber(ctx context.Context, __arg VerifyPhoneNumberArg) (err error) { 267 err = c.Cli.Call(ctx, "keybase.1.phoneNumbers.verifyPhoneNumber", []interface{}{__arg}, nil, 0*time.Millisecond) 268 return 269 } 270 271 func (c PhoneNumbersClient) ResendVerificationForPhoneNumber(ctx context.Context, __arg ResendVerificationForPhoneNumberArg) (err error) { 272 err = c.Cli.Call(ctx, "keybase.1.phoneNumbers.resendVerificationForPhoneNumber", []interface{}{__arg}, nil, 0*time.Millisecond) 273 return 274 } 275 276 func (c PhoneNumbersClient) GetPhoneNumbers(ctx context.Context, sessionID int) (res []UserPhoneNumber, err error) { 277 __arg := GetPhoneNumbersArg{SessionID: sessionID} 278 err = c.Cli.Call(ctx, "keybase.1.phoneNumbers.getPhoneNumbers", []interface{}{__arg}, &res, 0*time.Millisecond) 279 return 280 } 281 282 func (c PhoneNumbersClient) DeletePhoneNumber(ctx context.Context, __arg DeletePhoneNumberArg) (err error) { 283 err = c.Cli.Call(ctx, "keybase.1.phoneNumbers.deletePhoneNumber", []interface{}{__arg}, nil, 0*time.Millisecond) 284 return 285 } 286 287 func (c PhoneNumbersClient) SetVisibilityPhoneNumber(ctx context.Context, __arg SetVisibilityPhoneNumberArg) (err error) { 288 err = c.Cli.Call(ctx, "keybase.1.phoneNumbers.setVisibilityPhoneNumber", []interface{}{__arg}, nil, 0*time.Millisecond) 289 return 290 } 291 292 func (c PhoneNumbersClient) SetVisibilityAllPhoneNumber(ctx context.Context, __arg SetVisibilityAllPhoneNumberArg) (err error) { 293 err = c.Cli.Call(ctx, "keybase.1.phoneNumbers.setVisibilityAllPhoneNumber", []interface{}{__arg}, nil, 0*time.Millisecond) 294 return 295 }