1
1
import _ from 'lodash'
2
2
import { axiosInstance } from './axiosWithAuth'
3
- const { MEMBER_API_URL , MEMBER_API_V3_URL } = process . env
3
+ const { MEMBER_API_URL } = process . env
4
4
5
5
/**
6
6
* Api request for fetching user profile
7
7
* @returns {Promise<*> }
8
8
*/
9
9
export async function fetchProfile ( handle ) {
10
- const response = await axiosInstance . get ( `${ MEMBER_API_V3_URL } /${ handle } ` )
11
- return _ . get ( response , 'data.result.content' )
12
- }
13
-
14
- /**
15
- * Api request for fetching user profile v5
16
- * @returns {Promise<*> }
17
- */
18
- export async function fetchProfileV5 ( handle ) {
19
- const response = await axiosInstance . get ( `${ MEMBER_API_URL } ?handle=${ handle } ` )
20
- const data = _ . get ( response , 'data' )
21
- return data . length ? data [ 0 ] : undefined
10
+ const response = await axiosInstance . get ( `${ MEMBER_API_URL } /${ handle } ` )
11
+ return _ . get ( response , 'data' )
22
12
}
23
13
24
14
/**
25
- * Api request for fetching user profile
15
+ * Api request for searching profiles
26
16
* @returns {Promise<*> }
27
17
*/
28
- export async function searchProfiles ( fields , query , limit ) {
29
- const response = await axiosInstance . get ( `${ MEMBER_API_V3_URL } /_search ` , {
18
+ export async function searchProfiles ( fields , queryObject = { } , limit ) {
19
+ const response = await axiosInstance . get ( `${ MEMBER_API_URL } ` , {
30
20
params : {
31
21
fields,
32
- query,
33
- limit
22
+ ...queryObject ,
23
+ perPage : limit ,
24
+ page : 1
34
25
}
35
26
} )
36
27
return _ . get ( response , 'data.result.content' )
@@ -41,30 +32,20 @@ export async function searchProfiles (fields, query, limit) {
41
32
* @returns {Promise<*> }
42
33
*/
43
34
export async function searchProfilesByUserIds ( userIds , fields = 'userId,handle,firstName,lastName,email' , limit ) {
44
- const response = await axiosInstance . get ( `${ MEMBER_API_V3_URL } /_search` , {
45
- params : {
46
- query : `${ _ . map ( userIds , id => `userId:${ id } ` ) . join ( encodeURIComponent ( ' OR ' ) ) } ` ,
47
- fields,
48
- limit
49
- }
50
- } )
51
- return _ . get ( response , 'data.result.content' )
35
+ return searchProfiles (
36
+ fields ,
37
+ {
38
+ userIds
39
+ } ,
40
+ limit
41
+ )
52
42
}
53
43
54
44
/**
55
45
* Api request for finding (suggesting) users by the part of the handle
56
46
* @returns {Promise<*> }
57
47
*/
58
48
export async function suggestProfiles ( partialHandle ) {
59
- const response = await axiosInstance . get ( `${ MEMBER_API_V3_URL } /_suggest/${ encodeURIComponent ( partialHandle ) } ` )
60
- return _ . get ( response , 'data.result.content' )
61
- }
62
-
63
- /**
64
- * Api request for finding (suggesting) users by the part of the handle
65
- * @returns {Promise<*> }
66
- */
67
- export async function suggestProfilesV5 ( partialHandle ) {
68
49
const response = await axiosInstance . get ( `${ MEMBER_API_URL } /autocomplete?term=${ encodeURIComponent ( partialHandle ) } ` )
69
50
return _ . get ( response , 'data' )
70
51
}
0 commit comments