summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/SevereCloud/vksdk/v2/api/friends.go
blob: 07cfc7d712319d10e7c6981a0fb28aca055b0f25 (plain) (blame)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
package api // import "github.com/SevereCloud/vksdk/v2/api"

import (
	"github.com/SevereCloud/vksdk/v2/object"
)

// FriendsAdd approves or creates a friend request.
//
// https://vk.com/dev/friends.add
func (vk *VK) FriendsAdd(params Params) (response int, err error) {
	err = vk.RequestUnmarshal("friends.add", &response, params)
	return
}

// FriendsAddListResponse struct.
type FriendsAddListResponse struct {
	ListID int `json:"list_id"`
}

// FriendsAddList creates a new friend list for the current user.
//
// https://vk.com/dev/friends.addList
func (vk *VK) FriendsAddList(params Params) (response FriendsAddListResponse, err error) {
	err = vk.RequestUnmarshal("friends.addList", &response, params)
	return
}

// FriendsAreFriendsResponse struct.
type FriendsAreFriendsResponse []object.FriendsFriendStatus

// FriendsAreFriends checks the current user's friendship status with other specified users.
//
// https://vk.com/dev/friends.areFriends
func (vk *VK) FriendsAreFriends(params Params) (response FriendsAreFriendsResponse, err error) {
	err = vk.RequestUnmarshal("friends.areFriends", &response, params)
	return
}

// FriendsDeleteResponse struct.
type FriendsDeleteResponse struct {
	Success           object.BaseBoolInt `json:"success"`
	FriendDeleted     object.BaseBoolInt `json:"friend_deleted"`
	OutRequestDeleted object.BaseBoolInt `json:"out_request_deleted"`
	InRequestDeleted  object.BaseBoolInt `json:"in_request_deleted"`
	SuggestionDeleted object.BaseBoolInt `json:"suggestion_deleted"`
}

// FriendsDelete declines a friend request or deletes a user from the current user's friend list.
//
// https://vk.com/dev/friends.delete
func (vk *VK) FriendsDelete(params Params) (response FriendsDeleteResponse, err error) {
	err = vk.RequestUnmarshal("friends.delete", &response, params)
	return
}

// FriendsDeleteAllRequests marks all incoming friend requests as viewed.
//
// https://vk.com/dev/friends.deleteAllRequests
func (vk *VK) FriendsDeleteAllRequests(params Params) (response int, err error) {
	err = vk.RequestUnmarshal("friends.deleteAllRequests", &response, params)
	return
}

// FriendsDeleteList deletes a friend list of the current user.
//
// https://vk.com/dev/friends.deleteList
func (vk *VK) FriendsDeleteList(params Params) (response int, err error) {
	err = vk.RequestUnmarshal("friends.deleteList", &response, params)
	return
}

// FriendsEdit edits the friend lists of the selected user.
//
// https://vk.com/dev/friends.edit
func (vk *VK) FriendsEdit(params Params) (response int, err error) {
	err = vk.RequestUnmarshal("friends.edit", &response, params)
	return
}

// FriendsEditList edits a friend list of the current user.
//
// https://vk.com/dev/friends.editList
func (vk *VK) FriendsEditList(params Params) (response int, err error) {
	err = vk.RequestUnmarshal("friends.editList", &response, params)
	return
}

// FriendsGetResponse struct.
type FriendsGetResponse struct {
	Count int   `json:"count"`
	Items []int `json:"items"`
}

// FriendsGet returns a list of user IDs or detailed information about a user's friends.
//
// https://vk.com/dev/friends.get
func (vk *VK) FriendsGet(params Params) (response FriendsGetResponse, err error) {
	err = vk.RequestUnmarshal("friends.get", &response, params)
	return
}

// FriendsGetFieldsResponse struct.
type FriendsGetFieldsResponse struct {
	Count int                          `json:"count"`
	Items []object.FriendsUserXtrLists `json:"items"`
}

// FriendsGetFields returns a list of user IDs or detailed information about a user's friends.
//
// https://vk.com/dev/friends.get
func (vk *VK) FriendsGetFields(params Params) (response FriendsGetFieldsResponse, err error) {
	reqParams := make(Params)
	if v, prs := params["fields"]; v == "" || !prs {
		reqParams["fields"] = "id"
	}

	err = vk.RequestUnmarshal("friends.get", &response, params, reqParams)

	return
}

// FriendsGetAppUsersResponse struct.
type FriendsGetAppUsersResponse []int

// FriendsGetAppUsers returns a list of IDs of the current user's friends who installed the application.
//
// https://vk.com/dev/friends.getAppUsers
func (vk *VK) FriendsGetAppUsers(params Params) (response FriendsGetAppUsersResponse, err error) {
	err = vk.RequestUnmarshal("friends.getAppUsers", &response, params)
	return
}

// FriendsGetByPhonesResponse struct.
type FriendsGetByPhonesResponse []object.FriendsUserXtrPhone

// FriendsGetByPhones returns a list of the current user's friends
// whose phone numbers, validated or specified in a profile, are in a given list.
//
// https://vk.com/dev/friends.getByPhones
func (vk *VK) FriendsGetByPhones(params Params) (response FriendsGetByPhonesResponse, err error) {
	err = vk.RequestUnmarshal("friends.getByPhones", &response, params)
	return
}

// FriendsGetListsResponse struct.
type FriendsGetListsResponse struct {
	Count int                         `json:"count"`
	Items []object.FriendsFriendsList `json:"items"`
}

// FriendsGetLists returns a list of the user's friend lists.
//
// https://vk.com/dev/friends.getLists
func (vk *VK) FriendsGetLists(params Params) (response FriendsGetListsResponse, err error) {
	err = vk.RequestUnmarshal("friends.getLists", &response, params)
	return
}

// FriendsGetMutualResponse struct.
type FriendsGetMutualResponse []int

// FriendsGetMutual returns a list of user IDs of the mutual friends of two users.
//
// https://vk.com/dev/friends.getMutual
func (vk *VK) FriendsGetMutual(params Params) (response FriendsGetMutualResponse, err error) {
	err = vk.RequestUnmarshal("friends.getMutual", &response, params)
	return
}

// FriendsGetOnline returns a list of user IDs of a user's friends who are online.
//
// 	online_mobile=0
//
// https://vk.com/dev/friends.getOnline
func (vk *VK) FriendsGetOnline(params Params) (response []int, err error) {
	err = vk.RequestUnmarshal("friends.getOnline", &response, params, Params{"online_mobile": false})

	return
}

// FriendsGetOnlineOnlineMobileResponse struct.
type FriendsGetOnlineOnlineMobileResponse struct {
	Online       []int `json:"online"`
	OnlineMobile []int `json:"online_mobile"`
}

// FriendsGetOnlineOnlineMobile returns a list of user IDs of a user's friends who are online.
//
// 	online_mobile=1
//
// https://vk.com/dev/friends.getOnline
func (vk *VK) FriendsGetOnlineOnlineMobile(params Params) (response FriendsGetOnlineOnlineMobileResponse, err error) {
	err = vk.RequestUnmarshal("friends.getOnline", &response, params, Params{"online_mobile": true})

	return
}

// FriendsGetRecentResponse struct.
type FriendsGetRecentResponse []int

// FriendsGetRecent returns a list of user IDs of the current user's recently added friends.
//
// https://vk.com/dev/friends.getRecent
func (vk *VK) FriendsGetRecent(params Params) (response FriendsGetRecentResponse, err error) {
	err = vk.RequestUnmarshal("friends.getRecent", &response, params)
	return
}

// FriendsGetRequestsResponse struct.
type FriendsGetRequestsResponse struct {
	Count int   `json:"count"` // Total requests number
	Items []int `json:"items"`
}

// FriendsGetRequests returns information about the current user's incoming and outgoing friend requests.
//
// https://vk.com/dev/friends.getRequests
func (vk *VK) FriendsGetRequests(params Params) (response FriendsGetRequestsResponse, err error) {
	reqParams := Params{
		"need_mutual": false,
		"extended":    false,
	}

	err = vk.RequestUnmarshal("friends.getRequests", &response, params, reqParams)

	return
}

// FriendsGetRequestsNeedMutualResponse struct.
type FriendsGetRequestsNeedMutualResponse struct {
	Count int                      `json:"count"` // Total requests number
	Items []object.FriendsRequests `json:"items"`
}

// FriendsGetRequestsNeedMutual returns information about the current user's incoming and outgoing friend requests.
//
// https://vk.com/dev/friends.getRequests
func (vk *VK) FriendsGetRequestsNeedMutual(params Params) (response FriendsGetRequestsNeedMutualResponse, err error) {
	reqParams := Params{
		"extended":    false,
		"need_mutual": true,
	}

	err = vk.RequestUnmarshal("friends.getRequests", &response, params, reqParams)

	return
}

// FriendsGetRequestsExtendedResponse struct.
type FriendsGetRequestsExtendedResponse struct {
	Count int                                `json:"count"`
	Items []object.FriendsRequestsXtrMessage `json:"items"`
}

// FriendsGetRequestsExtended returns information about the current user's incoming and outgoing friend requests.
//
// https://vk.com/dev/friends.getRequests
func (vk *VK) FriendsGetRequestsExtended(params Params) (response FriendsGetRequestsExtendedResponse, err error) {
	reqParams := Params{
		"need_mutual": false,
		"extended":    true,
	}

	err = vk.RequestUnmarshal("friends.getRequests", &response, params, reqParams)

	return
}

// FriendsGetSuggestionsResponse struct.
type FriendsGetSuggestionsResponse struct {
	Count int                `json:"count"`
	Items []object.UsersUser `json:"items"`
}

// FriendsGetSuggestions returns a list of profiles of users whom the current user may know.
//
// https://vk.com/dev/friends.getSuggestions
func (vk *VK) FriendsGetSuggestions(params Params) (response FriendsGetSuggestionsResponse, err error) {
	err = vk.RequestUnmarshal("friends.getSuggestions", &response, params)
	return
}

// FriendsSearchResponse struct.
type FriendsSearchResponse struct {
	Count int                `json:"count"`
	Items []object.UsersUser `json:"items"`
}

// FriendsSearch returns a list of friends matching the search criteria.
//
// https://vk.com/dev/friends.search
func (vk *VK) FriendsSearch(params Params) (response FriendsSearchResponse, err error) {
	err = vk.RequestUnmarshal("friends.search", &response, params)
	return
}