github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/keybase1/contacts.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/contacts.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 type ContactComponent struct { 13 Label string `codec:"label" json:"label"` 14 PhoneNumber *RawPhoneNumber `codec:"phoneNumber,omitempty" json:"phoneNumber,omitempty"` 15 Email *EmailAddress `codec:"email,omitempty" json:"email,omitempty"` 16 } 17 18 func (o ContactComponent) DeepCopy() ContactComponent { 19 return ContactComponent{ 20 Label: o.Label, 21 PhoneNumber: (func(x *RawPhoneNumber) *RawPhoneNumber { 22 if x == nil { 23 return nil 24 } 25 tmp := (*x).DeepCopy() 26 return &tmp 27 })(o.PhoneNumber), 28 Email: (func(x *EmailAddress) *EmailAddress { 29 if x == nil { 30 return nil 31 } 32 tmp := (*x).DeepCopy() 33 return &tmp 34 })(o.Email), 35 } 36 } 37 38 type Contact struct { 39 Name string `codec:"name" json:"name"` 40 Components []ContactComponent `codec:"components" json:"components"` 41 } 42 43 func (o Contact) DeepCopy() Contact { 44 return Contact{ 45 Name: o.Name, 46 Components: (func(x []ContactComponent) []ContactComponent { 47 if x == nil { 48 return nil 49 } 50 ret := make([]ContactComponent, len(x)) 51 for i, v := range x { 52 vCopy := v.DeepCopy() 53 ret[i] = vCopy 54 } 55 return ret 56 })(o.Components), 57 } 58 } 59 60 type ProcessedContact struct { 61 ContactIndex int `codec:"contactIndex" json:"contactIndex"` 62 ContactName string `codec:"contactName" json:"contactName"` 63 Component ContactComponent `codec:"component" json:"component"` 64 Resolved bool `codec:"resolved" json:"resolved"` 65 Uid UID `codec:"uid" json:"uid"` 66 Username string `codec:"username" json:"username"` 67 FullName string `codec:"fullName" json:"fullName"` 68 Following bool `codec:"following" json:"following"` 69 ServiceMap map[string]string `codec:"serviceMap" json:"serviceMap"` 70 Assertion string `codec:"assertion" json:"assertion"` 71 DisplayName string `codec:"displayName" json:"displayName"` 72 DisplayLabel string `codec:"displayLabel" json:"displayLabel"` 73 } 74 75 func (o ProcessedContact) DeepCopy() ProcessedContact { 76 return ProcessedContact{ 77 ContactIndex: o.ContactIndex, 78 ContactName: o.ContactName, 79 Component: o.Component.DeepCopy(), 80 Resolved: o.Resolved, 81 Uid: o.Uid.DeepCopy(), 82 Username: o.Username, 83 FullName: o.FullName, 84 Following: o.Following, 85 ServiceMap: (func(x map[string]string) map[string]string { 86 if x == nil { 87 return nil 88 } 89 ret := make(map[string]string, len(x)) 90 for k, v := range x { 91 kCopy := k 92 vCopy := v 93 ret[kCopy] = vCopy 94 } 95 return ret 96 })(o.ServiceMap), 97 Assertion: o.Assertion, 98 DisplayName: o.DisplayName, 99 DisplayLabel: o.DisplayLabel, 100 } 101 } 102 103 type ContactListResolutionResult struct { 104 NewlyResolved []ProcessedContact `codec:"newlyResolved" json:"newlyResolved"` 105 Resolved []ProcessedContact `codec:"resolved" json:"resolved"` 106 } 107 108 func (o ContactListResolutionResult) DeepCopy() ContactListResolutionResult { 109 return ContactListResolutionResult{ 110 NewlyResolved: (func(x []ProcessedContact) []ProcessedContact { 111 if x == nil { 112 return nil 113 } 114 ret := make([]ProcessedContact, len(x)) 115 for i, v := range x { 116 vCopy := v.DeepCopy() 117 ret[i] = vCopy 118 } 119 return ret 120 })(o.NewlyResolved), 121 Resolved: (func(x []ProcessedContact) []ProcessedContact { 122 if x == nil { 123 return nil 124 } 125 ret := make([]ProcessedContact, len(x)) 126 for i, v := range x { 127 vCopy := v.DeepCopy() 128 ret[i] = vCopy 129 } 130 return ret 131 })(o.Resolved), 132 } 133 } 134 135 type LookupContactListArg struct { 136 SessionID int `codec:"sessionID" json:"sessionID"` 137 Contacts []Contact `codec:"contacts" json:"contacts"` 138 } 139 140 type SaveContactListArg struct { 141 SessionID int `codec:"sessionID" json:"sessionID"` 142 Contacts []Contact `codec:"contacts" json:"contacts"` 143 } 144 145 type LookupSavedContactsListArg struct { 146 SessionID int `codec:"sessionID" json:"sessionID"` 147 } 148 149 type GetContactsForUserRecommendationsArg struct { 150 SessionID int `codec:"sessionID" json:"sessionID"` 151 } 152 153 type ContactsInterface interface { 154 LookupContactList(context.Context, LookupContactListArg) ([]ProcessedContact, error) 155 SaveContactList(context.Context, SaveContactListArg) (ContactListResolutionResult, error) 156 LookupSavedContactsList(context.Context, int) ([]ProcessedContact, error) 157 GetContactsForUserRecommendations(context.Context, int) ([]ProcessedContact, error) 158 } 159 160 func ContactsProtocol(i ContactsInterface) rpc.Protocol { 161 return rpc.Protocol{ 162 Name: "keybase.1.contacts", 163 Methods: map[string]rpc.ServeHandlerDescription{ 164 "lookupContactList": { 165 MakeArg: func() interface{} { 166 var ret [1]LookupContactListArg 167 return &ret 168 }, 169 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 170 typedArgs, ok := args.(*[1]LookupContactListArg) 171 if !ok { 172 err = rpc.NewTypeError((*[1]LookupContactListArg)(nil), args) 173 return 174 } 175 ret, err = i.LookupContactList(ctx, typedArgs[0]) 176 return 177 }, 178 }, 179 "saveContactList": { 180 MakeArg: func() interface{} { 181 var ret [1]SaveContactListArg 182 return &ret 183 }, 184 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 185 typedArgs, ok := args.(*[1]SaveContactListArg) 186 if !ok { 187 err = rpc.NewTypeError((*[1]SaveContactListArg)(nil), args) 188 return 189 } 190 ret, err = i.SaveContactList(ctx, typedArgs[0]) 191 return 192 }, 193 }, 194 "lookupSavedContactsList": { 195 MakeArg: func() interface{} { 196 var ret [1]LookupSavedContactsListArg 197 return &ret 198 }, 199 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 200 typedArgs, ok := args.(*[1]LookupSavedContactsListArg) 201 if !ok { 202 err = rpc.NewTypeError((*[1]LookupSavedContactsListArg)(nil), args) 203 return 204 } 205 ret, err = i.LookupSavedContactsList(ctx, typedArgs[0].SessionID) 206 return 207 }, 208 }, 209 "getContactsForUserRecommendations": { 210 MakeArg: func() interface{} { 211 var ret [1]GetContactsForUserRecommendationsArg 212 return &ret 213 }, 214 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 215 typedArgs, ok := args.(*[1]GetContactsForUserRecommendationsArg) 216 if !ok { 217 err = rpc.NewTypeError((*[1]GetContactsForUserRecommendationsArg)(nil), args) 218 return 219 } 220 ret, err = i.GetContactsForUserRecommendations(ctx, typedArgs[0].SessionID) 221 return 222 }, 223 }, 224 }, 225 } 226 } 227 228 type ContactsClient struct { 229 Cli rpc.GenericClient 230 } 231 232 func (c ContactsClient) LookupContactList(ctx context.Context, __arg LookupContactListArg) (res []ProcessedContact, err error) { 233 err = c.Cli.Call(ctx, "keybase.1.contacts.lookupContactList", []interface{}{__arg}, &res, 0*time.Millisecond) 234 return 235 } 236 237 func (c ContactsClient) SaveContactList(ctx context.Context, __arg SaveContactListArg) (res ContactListResolutionResult, err error) { 238 err = c.Cli.Call(ctx, "keybase.1.contacts.saveContactList", []interface{}{__arg}, &res, 0*time.Millisecond) 239 return 240 } 241 242 func (c ContactsClient) LookupSavedContactsList(ctx context.Context, sessionID int) (res []ProcessedContact, err error) { 243 __arg := LookupSavedContactsListArg{SessionID: sessionID} 244 err = c.Cli.Call(ctx, "keybase.1.contacts.lookupSavedContactsList", []interface{}{__arg}, &res, 0*time.Millisecond) 245 return 246 } 247 248 func (c ContactsClient) GetContactsForUserRecommendations(ctx context.Context, sessionID int) (res []ProcessedContact, err error) { 249 __arg := GetContactsForUserRecommendationsArg{SessionID: sessionID} 250 err = c.Cli.Call(ctx, "keybase.1.contacts.getContactsForUserRecommendations", []interface{}{__arg}, &res, 0*time.Millisecond) 251 return 252 }