@selfcommunity/api-services 0.4.8 → 0.4.9-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1119,6 +1119,73 @@ const Endpoints = {
1119
1119
  GetSpecificReaction: {
1120
1120
  url: urlReplacer('/api/v2/reaction/$(id)/'),
1121
1121
  method: 'GET'
1122
+ },
1123
+ /**
1124
+ * Groups
1125
+ */
1126
+ GetUserGroups: {
1127
+ url: urlReplacer('/api/v2/group/'),
1128
+ method: 'GET'
1129
+ },
1130
+ GetGroupInfo: {
1131
+ url: urlReplacer('/api/v2/group/$(id)/'),
1132
+ method: 'GET'
1133
+ },
1134
+ GetGroupFeed: {
1135
+ url: urlReplacer('/api/v2/group/$(id)/feed/'),
1136
+ method: 'GET'
1137
+ },
1138
+ SearchGroups: {
1139
+ url: urlReplacer('/api/v2/group/$(id)/search/'),
1140
+ method: 'GET'
1141
+ },
1142
+ CreateGroup: {
1143
+ url: urlReplacer('/api/v2/group/'),
1144
+ method: 'POST'
1145
+ },
1146
+ UpdateGroup: {
1147
+ url: urlReplacer('/api/v2/group/$(id)/'),
1148
+ method: 'PUT'
1149
+ },
1150
+ PatchGroup: {
1151
+ url: urlReplacer('/api/v2/group/$(id)/'),
1152
+ method: 'PATCH'
1153
+ },
1154
+ GetGroupSuggestedUsers: {
1155
+ url: urlReplacer('/api/v2/group/$(id)/user/?search=$(search)'),
1156
+ method: 'GET'
1157
+ },
1158
+ GetGroupsSuggestedUsers: {
1159
+ url: urlReplacer('/api/v2/group/user/?search=$(search)'),
1160
+ method: 'GET'
1161
+ },
1162
+ InviteOrAcceptGroupRequest: {
1163
+ url: urlReplacer('/api/v2/group/$(id)/invite/'),
1164
+ method: 'POST'
1165
+ },
1166
+ GetGroupInvitedUsers: {
1167
+ url: urlReplacer('/api/v2/group/$(id)/invite/'),
1168
+ method: 'GET'
1169
+ },
1170
+ GetGroupSubscriptionStatus: {
1171
+ url: urlReplacer('/api/v2/group/$(id)/status/'),
1172
+ method: 'GET'
1173
+ },
1174
+ SubscribeToGroup: {
1175
+ url: urlReplacer('/api/v2/group/$(id)/subscribe/'),
1176
+ method: 'POST'
1177
+ },
1178
+ GetGroupSubscribers: {
1179
+ url: urlReplacer('/api/v2/group/$(id)/subscribe/'),
1180
+ method: 'GET'
1181
+ },
1182
+ GetGroupWaitingApprovalSubscribers: {
1183
+ url: urlReplacer('/api/v2/group/$(id)/request_subscribe/'),
1184
+ method: 'GET'
1185
+ },
1186
+ UnsubscribeFromGroup: {
1187
+ url: urlReplacer('/api/v2/group/$(id)/subscribe/'),
1188
+ method: 'DELETE'
1122
1189
  }
1123
1190
  };
1124
1191
  export default Endpoints;
@@ -46,11 +46,12 @@ import TagService, { TagApiClient, TagApiClientInterface } from './services/tag'
46
46
  import UserService, { UserApiClient, UserApiClientInterface } from './services/user';
47
47
  import WebhookService, { WebhookApiClient, WebhookApiClientInterface } from './services/webhook';
48
48
  import ReactionService, { ReactionApiClient, ReactionApiClientInterface } from './services/reactions';
49
+ import GroupService, { GroupApiClient, GroupApiClientInterface } from './services/group';
49
50
  /**
50
51
  * Types
51
52
  */
52
- import { AccountCreateParams, AccountVerifyParams, AccountResetParams, AccountRecoverParams, AccountSearchParams, SCPaginatedResponse, WebhookParamType, WebhookEventsType, SSOSignUpParams, CommentListParams, CommentCreateParams, IncubatorCreateParams, IncubatorSearchParams, LoyaltyPrizeParams, LoyaltyGetPrizeParams, ModerationParams, ModerateContributionParams, FlaggedContributionParams, CustomNotificationParams, UserAutocompleteParams, UserScoreParams, UserSearchParams, TagParams, TagGetParams, MediaCreateParams, MediaTypes, ChunkUploadParams, ChunkUploadCompleteParams, ThreadParams, MessageCreateParams, MessageMediaUploadParams, MessageThumbnailUploadParams, MessageChunkUploadDoneParams, MessageMediaChunksParams, CategoryParams, CustomAdvParams, CustomPageParams, CustomPageSearchParams, EmbedUpdateParams, EmbedSearchParams, BaseGetParams, BaseSearchParams, FeedObjGetParams, FeedObjCreateParams, FeedObjectPollVotesSearch, FeedParams, LegalPageFilterParams, FeatureParams, ScoreParams, InsightContributionParams, InsightUserParams, InsightEmbedParams, InsightCommonParams, ReactionParams } from './types';
53
+ import { AccountCreateParams, AccountVerifyParams, AccountResetParams, AccountRecoverParams, AccountSearchParams, SCPaginatedResponse, WebhookParamType, WebhookEventsType, SSOSignUpParams, CommentListParams, CommentCreateParams, IncubatorCreateParams, IncubatorSearchParams, LoyaltyPrizeParams, LoyaltyGetPrizeParams, ModerationParams, ModerateContributionParams, FlaggedContributionParams, CustomNotificationParams, UserAutocompleteParams, UserScoreParams, UserSearchParams, TagParams, TagGetParams, MediaCreateParams, MediaTypes, ChunkUploadParams, ChunkUploadCompleteParams, ThreadParams, MessageCreateParams, MessageMediaUploadParams, MessageThumbnailUploadParams, MessageChunkUploadDoneParams, MessageMediaChunksParams, CategoryParams, CustomAdvParams, CustomPageParams, CustomPageSearchParams, EmbedUpdateParams, EmbedSearchParams, BaseGetParams, BaseSearchParams, FeedObjGetParams, FeedObjCreateParams, FeedObjectPollVotesSearch, FeedParams, LegalPageFilterParams, FeatureParams, ScoreParams, InsightContributionParams, InsightUserParams, InsightEmbedParams, InsightCommonParams, ReactionParams, GroupCreateParams, GroupFeedParams } from './types';
53
54
  /**
54
55
  * Export all
55
56
  */
56
- export { http, HttpResponse, HttpMethod, apiRequest, formatHttpError, formatHttpErrorCode, getCancelTokenSourceRequest, generateJWTToken, parseJwt, urlParams, Endpoints, EndpointType, AccountService, AccountApiClient, AccountApiClientInterface, PreferenceService, PreferenceApiClient, PreferenceApiClientInterface, UserService, UserApiClient, UserApiClientInterface, FeatureService, FeatureApiClient, FeatureApiClientInterface, CategoryService, CategoryApiClient, CategoryApiClientInterface, CommentService, CommentApiClient, CommentApiClientInterface, CustomAdvService, CustomAdvApiClient, CustomAdvApiClientInterface, CustomMenuService, CustomMenuApiClient, CustomMenuApiClientInterface, CustomPageService, CustomPageApiClient, CustomPageApiClientInterface, DataPortabilityService, DataPortabilityApiClient, DataPortabilityApiClientInterface, EmbedService, EmbedApiClient, EmbedApiClientInterface, FeedService, FeedApiClient, FeedApiClientInterface, FeedObjectService, FeedObjectApiClient, FeedObjectApiClientInterface, IncubatorService, IncubatorApiClient, IncubatorApiClientInterface, InsightService, InsightApiClient, InsightApiClientInterface, InviteService, InviteApiClient, InviteApiClientInterface, LegalPageService, LegalPageApiClient, LegalPageApiClientInterface, LocalityService, LocalityApiClient, LocalityApiClientInterface, LoyaltyService, LoyaltyApiClient, LoyaltyApiClientInterface, MediaService, MediaApiClient, MediaApiClientInterface, ModerationService, ModerationApiClient, ModerationApiClientInterface, NotificationService, NotificationApiClient, NotificationApiClientInterface, PrivateMessageService, PrivateMessageApiClient, PrivateMessageApiClientInterface, PromoService, PromoApiClient, PromoApiClientInterface, ScoreService, ScoreApiClient, ScoreApiClientInterface, SSOService, SSOApiClient, SSOApiClientInterface, SuggestionService, SuggestionApiClient, SuggestionApiClientInterface, TagService, TagApiClient, TagApiClientInterface, WebhookService, WebhookApiClient, WebhookApiClientInterface, SCPaginatedResponse, WebhookParamType, WebhookEventsType, AccountSearchParams, AccountCreateParams, AccountVerifyParams, AccountResetParams, AccountRecoverParams, CommentCreateParams, IncubatorCreateParams, IncubatorSearchParams, SSOSignUpParams, CommentListParams, LoyaltyPrizeParams, LoyaltyGetPrizeParams, ModerationParams, FlaggedContributionParams, ModerateContributionParams, CustomNotificationParams, UserAutocompleteParams, UserScoreParams, UserSearchParams, TagParams, TagGetParams, MediaCreateParams, MediaTypes, ChunkUploadParams, ChunkUploadCompleteParams, ThreadParams, MessageCreateParams, MessageMediaUploadParams, MessageThumbnailUploadParams, MessageChunkUploadDoneParams, MessageMediaChunksParams, CategoryParams, CustomAdvParams, CustomPageParams, CustomPageSearchParams, EmbedUpdateParams, EmbedSearchParams, BaseGetParams, BaseSearchParams, FeedObjGetParams, FeedObjCreateParams, FeedObjectPollVotesSearch, FeedParams, LegalPageFilterParams, FeatureParams, ScoreParams, InsightContributionParams, InsightUserParams, InsightEmbedParams, InsightCommonParams, ReactionParams, ReactionService, ReactionApiClient, ReactionApiClientInterface };
57
+ export { http, HttpResponse, HttpMethod, apiRequest, formatHttpError, formatHttpErrorCode, getCancelTokenSourceRequest, generateJWTToken, parseJwt, urlParams, Endpoints, EndpointType, AccountService, AccountApiClient, AccountApiClientInterface, PreferenceService, PreferenceApiClient, PreferenceApiClientInterface, UserService, UserApiClient, UserApiClientInterface, FeatureService, FeatureApiClient, FeatureApiClientInterface, CategoryService, CategoryApiClient, CategoryApiClientInterface, CommentService, CommentApiClient, CommentApiClientInterface, CustomAdvService, CustomAdvApiClient, CustomAdvApiClientInterface, CustomMenuService, CustomMenuApiClient, CustomMenuApiClientInterface, CustomPageService, CustomPageApiClient, CustomPageApiClientInterface, DataPortabilityService, DataPortabilityApiClient, DataPortabilityApiClientInterface, EmbedService, EmbedApiClient, EmbedApiClientInterface, FeedService, FeedApiClient, FeedApiClientInterface, FeedObjectService, FeedObjectApiClient, FeedObjectApiClientInterface, IncubatorService, IncubatorApiClient, IncubatorApiClientInterface, InsightService, InsightApiClient, InsightApiClientInterface, InviteService, InviteApiClient, InviteApiClientInterface, LegalPageService, LegalPageApiClient, LegalPageApiClientInterface, LocalityService, LocalityApiClient, LocalityApiClientInterface, LoyaltyService, LoyaltyApiClient, LoyaltyApiClientInterface, MediaService, MediaApiClient, MediaApiClientInterface, ModerationService, ModerationApiClient, ModerationApiClientInterface, NotificationService, NotificationApiClient, NotificationApiClientInterface, PrivateMessageService, PrivateMessageApiClient, PrivateMessageApiClientInterface, PromoService, PromoApiClient, PromoApiClientInterface, ScoreService, ScoreApiClient, ScoreApiClientInterface, SSOService, SSOApiClient, SSOApiClientInterface, SuggestionService, SuggestionApiClient, SuggestionApiClientInterface, TagService, TagApiClient, TagApiClientInterface, WebhookService, WebhookApiClient, WebhookApiClientInterface, SCPaginatedResponse, WebhookParamType, WebhookEventsType, AccountSearchParams, AccountCreateParams, AccountVerifyParams, AccountResetParams, AccountRecoverParams, CommentCreateParams, IncubatorCreateParams, IncubatorSearchParams, SSOSignUpParams, CommentListParams, LoyaltyPrizeParams, LoyaltyGetPrizeParams, ModerationParams, FlaggedContributionParams, ModerateContributionParams, CustomNotificationParams, UserAutocompleteParams, UserScoreParams, UserSearchParams, TagParams, TagGetParams, MediaCreateParams, MediaTypes, ChunkUploadParams, ChunkUploadCompleteParams, ThreadParams, MessageCreateParams, MessageMediaUploadParams, MessageThumbnailUploadParams, MessageChunkUploadDoneParams, MessageMediaChunksParams, CategoryParams, CustomAdvParams, CustomPageParams, CustomPageSearchParams, EmbedUpdateParams, EmbedSearchParams, BaseGetParams, BaseSearchParams, FeedObjGetParams, FeedObjCreateParams, FeedObjectPollVotesSearch, FeedParams, LegalPageFilterParams, FeatureParams, ScoreParams, InsightContributionParams, InsightUserParams, InsightEmbedParams, InsightCommonParams, ReactionParams, ReactionService, ReactionApiClient, ReactionApiClientInterface, GroupCreateParams, GroupFeedParams, GroupService, GroupApiClient, GroupApiClientInterface };
package/lib/esm/index.js CHANGED
@@ -46,6 +46,7 @@ import TagService, { TagApiClient } from './services/tag';
46
46
  import UserService, { UserApiClient } from './services/user';
47
47
  import WebhookService, { WebhookApiClient } from './services/webhook';
48
48
  import ReactionService, { ReactionApiClient } from './services/reactions';
49
+ import GroupService, { GroupApiClient } from './services/group';
49
50
  /**
50
51
  * Types
51
52
  */
@@ -53,4 +54,4 @@ import { MediaTypes } from './types';
53
54
  /**
54
55
  * Export all
55
56
  */
56
- export { http, apiRequest, formatHttpError, formatHttpErrorCode, getCancelTokenSourceRequest, generateJWTToken, parseJwt, urlParams, Endpoints, AccountService, AccountApiClient, PreferenceService, PreferenceApiClient, UserService, UserApiClient, FeatureService, FeatureApiClient, CategoryService, CategoryApiClient, CommentService, CommentApiClient, CustomAdvService, CustomAdvApiClient, CustomMenuService, CustomMenuApiClient, CustomPageService, CustomPageApiClient, DataPortabilityService, DataPortabilityApiClient, EmbedService, EmbedApiClient, FeedService, FeedApiClient, FeedObjectService, FeedObjectApiClient, IncubatorService, IncubatorApiClient, InsightService, InsightApiClient, InviteService, InviteApiClient, LegalPageService, LegalPageApiClient, LocalityService, LocalityApiClient, LoyaltyService, LoyaltyApiClient, MediaService, MediaApiClient, ModerationService, ModerationApiClient, NotificationService, NotificationApiClient, PrivateMessageService, PrivateMessageApiClient, PromoService, PromoApiClient, ScoreService, ScoreApiClient, SSOService, SSOApiClient, SuggestionService, SuggestionApiClient, TagService, TagApiClient, WebhookService, WebhookApiClient, MediaTypes, ReactionService, ReactionApiClient };
57
+ export { http, apiRequest, formatHttpError, formatHttpErrorCode, getCancelTokenSourceRequest, generateJWTToken, parseJwt, urlParams, Endpoints, AccountService, AccountApiClient, PreferenceService, PreferenceApiClient, UserService, UserApiClient, FeatureService, FeatureApiClient, CategoryService, CategoryApiClient, CommentService, CommentApiClient, CustomAdvService, CustomAdvApiClient, CustomMenuService, CustomMenuApiClient, CustomPageService, CustomPageApiClient, DataPortabilityService, DataPortabilityApiClient, EmbedService, EmbedApiClient, FeedService, FeedApiClient, FeedObjectService, FeedObjectApiClient, IncubatorService, IncubatorApiClient, InsightService, InsightApiClient, InviteService, InviteApiClient, LegalPageService, LegalPageApiClient, LocalityService, LocalityApiClient, LoyaltyService, LoyaltyApiClient, MediaService, MediaApiClient, ModerationService, ModerationApiClient, NotificationService, NotificationApiClient, PrivateMessageService, PrivateMessageApiClient, PromoService, PromoApiClient, ScoreService, ScoreApiClient, SSOService, SSOApiClient, SuggestionService, SuggestionApiClient, TagService, TagApiClient, WebhookService, WebhookApiClient, MediaTypes, ReactionService, ReactionApiClient, GroupService, GroupApiClient };
@@ -0,0 +1,198 @@
1
+ import { BaseGetParams, BaseSearchParams, GroupFeedParams, SCPaginatedResponse } from '../../types';
2
+ import { SCGroupType, SCUserType } from '@selfcommunity/types';
3
+ import { AxiosRequestConfig } from 'axios';
4
+ import { GroupCreateParams } from '../../types';
5
+ export interface GroupApiClientInterface {
6
+ getUserGroups(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
7
+ searchGroups(params?: BaseSearchParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
8
+ getSpecificGroupInfo(id: number | string, config?: AxiosRequestConfig): Promise<SCGroupType>;
9
+ getGroupFeed(id: number | string, params?: GroupFeedParams, config?: AxiosRequestConfig): Promise<any>;
10
+ createGroup(data: GroupCreateParams | FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
11
+ updateGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
12
+ patchGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
13
+ changeGroupAvatarOrCover(id: number | string, data: FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
14
+ getGroupMembers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
15
+ getGroupSuggestedUsers(id: number | string, search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
16
+ getGroupsSuggestedUsers(search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
17
+ getGroupInvitedUsers(id: number | string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
18
+ subscribeToGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
19
+ unsubscribeFromGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
20
+ inviteOrAcceptGroupRequest(id: number | string, data: {
21
+ users: number[];
22
+ }, config?: AxiosRequestConfig): Promise<any>;
23
+ getGroupSubscriptionStatus(id: number | string, config?: AxiosRequestConfig): Promise<any>;
24
+ getGroupWaitingApprovalSubscribers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
25
+ }
26
+ /**
27
+ * Contains all the endpoints needed to manage groups.
28
+ */
29
+ export declare class GroupApiClient {
30
+ /**
31
+ * This endpoint retrieves all the groups of the logged-in user.
32
+ * @param params
33
+ * @param config
34
+ */
35
+ static getUserGroups(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
36
+ /**
37
+ * This endpoint performs groups search
38
+ * @param params
39
+ * @param config
40
+ */
41
+ static searchGroups(params?: BaseSearchParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
42
+ /**
43
+ * This endpoint retrieves a specific group.
44
+ * @param id
45
+ * @param config
46
+ */
47
+ static getSpecificGroupInfo(id: number | string, config?: AxiosRequestConfig): Promise<SCGroupType>;
48
+ /**
49
+ * This endpoint performs groups search
50
+ * @param id
51
+ * @param params
52
+ * @param config
53
+ */
54
+ static getGroupFeed(id: number | string, params?: GroupFeedParams, config?: AxiosRequestConfig): Promise<any>;
55
+ /**
56
+ * This endpoint creates a group.
57
+ * @param data
58
+ * @param config
59
+ */
60
+ static createGroup(data: GroupCreateParams | FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
61
+ /**
62
+ * This endpoint updates a group.
63
+ * @param id
64
+ * @param data
65
+ * @param config
66
+ */
67
+ static updateGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
68
+ /**
69
+ * This endpoint patches a group.
70
+ * @param id
71
+ * @param data
72
+ * @param config
73
+ */
74
+ static patchGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
75
+ /**
76
+ * This endpoint changes the group avatar
77
+ * @param id
78
+ * @param data
79
+ * @param config
80
+ */
81
+ static changeGroupAvatarOrCover(id: number | string, data: FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
82
+ /**
83
+ * This endpoint returns all subscribers of a specific group.
84
+ * @param id
85
+ * @param params
86
+ * @param config
87
+ */
88
+ static getGroupMembers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
89
+ /**
90
+ * This endpoint returns a list of suggested users to invite to the group.
91
+ * @param id
92
+ * @param search
93
+ * @param config
94
+ */
95
+ static getGroupSuggestedUsers(id: number | string, search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
96
+ /**
97
+ * This endpoint returns a list of suggested users to invite to the groups.
98
+ * @param search
99
+ * @param config
100
+ */
101
+ static getGroupsSuggestedUsers(search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
102
+ /**
103
+ * This endpoint returns a list of invited users.
104
+ * @param id
105
+ * @param config
106
+ */
107
+ static getGroupInvitedUsers(id: number | string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
108
+ /**
109
+ * This endpoint subscribes to a group.
110
+ * @param id
111
+ * @param config
112
+ */
113
+ static subscribeToGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
114
+ /**
115
+ * This endpoint unsubscribes from a group.
116
+ * @param id
117
+ * @param config
118
+ */
119
+ static unsubscribeFromGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
120
+ /**
121
+ * This endpoint allows to invite or accept a group invite.
122
+ * @param id
123
+ * @param data
124
+ * @param config
125
+ */
126
+ static inviteOrAcceptGroupRequest(id: number | string, data: {
127
+ users: number[];
128
+ }, config?: AxiosRequestConfig): Promise<any>;
129
+ /**
130
+ * This endpoint retrieves the group subscription status.
131
+ * @param id
132
+ * @param config
133
+ */
134
+ static getGroupSubscriptionStatus(id: number | string, config?: AxiosRequestConfig): Promise<any>;
135
+ /**
136
+ * This endpoint returns a list of the users waiting to be added to the group.
137
+ * @param id
138
+ * @param params
139
+ * @param config
140
+ */
141
+ static getGroupWaitingApprovalSubscribers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
142
+ }
143
+ /**
144
+ *
145
+ :::tip Incubator service can be used in the following way:
146
+
147
+ ```jsx
148
+ 1. Import the service from our library:
149
+
150
+ import {GroupService} from "@selfcommunity/api-services";
151
+ ```
152
+ ```jsx
153
+ 2. Create a function and put the service inside it!
154
+ The async function `searchGroups` will return the groups matching the search query.
155
+
156
+ async searchGroups() {
157
+ return await GroupService.searchGroups();
158
+ }
159
+ ```
160
+ ```jsx
161
+ In case of required `params`, just add them inside the brackets.
162
+
163
+ async getSpecificGroupInfo(groupId) {
164
+ return await GroupService.getSpecificGroupInfo(groupId);
165
+ }
166
+ ```
167
+ ```jsx
168
+ If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
169
+
170
+ 1. Declare it(or declare them, it is possible to add multiple params)
171
+
172
+ const headers = headers: {Authorization: `Bearer ${yourToken}`}
173
+
174
+ 2. Add it inside the brackets and pass it to the function, as shown in the previous example!
175
+ ```
176
+ :::
177
+ */
178
+ export default class GroupService {
179
+ static getUserGroups(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
180
+ static searchGroups(params?: BaseSearchParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
181
+ static getSpecificGroupInfo(id: number | string, config?: AxiosRequestConfig): Promise<SCGroupType>;
182
+ static getGroupFeed(id: number | string, params?: GroupFeedParams, config?: AxiosRequestConfig): Promise<any>;
183
+ static createGroup(data: GroupCreateParams | FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
184
+ static updateGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
185
+ static patchGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
186
+ static changeGroupAvatarOrCover(id: number | string, data: FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
187
+ static getGroupMembers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
188
+ static getGroupSuggestedUsers(id: number | string, search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
189
+ static getGroupsSuggestedUsers(search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
190
+ static getGroupInvitedUsers(id: number | string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
191
+ static subscribeToGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
192
+ static unsubscribeFromGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
193
+ static inviteOrAcceptGroupRequest(id: number | string, data: {
194
+ users: number[];
195
+ }, config?: AxiosRequestConfig): Promise<any>;
196
+ static getGroupSubscriptionStatus(id: number | string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<any>>;
197
+ static getGroupWaitingApprovalSubscribers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
198
+ }
@@ -0,0 +1,280 @@
1
+ import { __awaiter } from "tslib";
2
+ import { apiRequest } from '../../utils/apiRequest';
3
+ import Endpoints from '../../constants/Endpoints';
4
+ import { urlParams } from '../../utils/url';
5
+ /**
6
+ * Contains all the endpoints needed to manage groups.
7
+ */
8
+ export class GroupApiClient {
9
+ /**
10
+ * This endpoint retrieves all the groups of the logged-in user.
11
+ * @param params
12
+ * @param config
13
+ */
14
+ static getUserGroups(params, config) {
15
+ const p = urlParams(params);
16
+ return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetUserGroups.url({})}?${p.toString()}`, method: Endpoints.GetUserGroups.method }));
17
+ }
18
+ /**
19
+ * This endpoint performs groups search
20
+ * @param params
21
+ * @param config
22
+ */
23
+ static searchGroups(params, config) {
24
+ const p = urlParams(params);
25
+ return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.SearchGroups.url({})}?${p.toString()}`, method: Endpoints.SearchGroups.method }));
26
+ }
27
+ /**
28
+ * This endpoint retrieves a specific group.
29
+ * @param id
30
+ * @param config
31
+ */
32
+ static getSpecificGroupInfo(id, config) {
33
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetGroupInfo.url({ id }), method: Endpoints.GetGroupInfo.method }));
34
+ }
35
+ /**
36
+ * This endpoint performs groups search
37
+ * @param id
38
+ * @param params
39
+ * @param config
40
+ */
41
+ static getGroupFeed(id, params, config) {
42
+ const p = urlParams(params);
43
+ return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetGroupFeed.url({ id })}?${p.toString()}`, method: Endpoints.GetGroupFeed.method }));
44
+ }
45
+ /**
46
+ * This endpoint creates a group.
47
+ * @param data
48
+ * @param config
49
+ */
50
+ static createGroup(data, config) {
51
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.CreateGroup.url({}), method: Endpoints.CreateGroup.method, data: data }));
52
+ }
53
+ /**
54
+ * This endpoint updates a group.
55
+ * @param id
56
+ * @param data
57
+ * @param config
58
+ */
59
+ static updateGroup(id, data, config) {
60
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.UpdateGroup.url({ id }), method: Endpoints.UpdateGroup.method, data: data }));
61
+ }
62
+ /**
63
+ * This endpoint patches a group.
64
+ * @param id
65
+ * @param data
66
+ * @param config
67
+ */
68
+ static patchGroup(id, data, config) {
69
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.PatchGroup.url({ id }), method: Endpoints.PatchGroup.method, data: data }));
70
+ }
71
+ /**
72
+ * This endpoint changes the group avatar
73
+ * @param id
74
+ * @param data
75
+ * @param config
76
+ */
77
+ static changeGroupAvatarOrCover(id, data, config) {
78
+ return apiRequest(Object.assign({ url: Endpoints.PatchGroup.url({ id }), method: Endpoints.PatchGroup.method, data }, config));
79
+ }
80
+ /**
81
+ * This endpoint returns all subscribers of a specific group.
82
+ * @param id
83
+ * @param params
84
+ * @param config
85
+ */
86
+ static getGroupMembers(id, params, config) {
87
+ const p = urlParams(params);
88
+ return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetGroupSubscribers.url({ id })}?${p.toString()}`, method: Endpoints.GetGroupSubscribers.method }));
89
+ }
90
+ /**
91
+ * This endpoint returns a list of suggested users to invite to the group.
92
+ * @param id
93
+ * @param search
94
+ * @param config
95
+ */
96
+ static getGroupSuggestedUsers(id, search, config) {
97
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetGroupSuggestedUsers.url({ id, search }), method: Endpoints.GetGroupSuggestedUsers.method }));
98
+ }
99
+ /**
100
+ * This endpoint returns a list of suggested users to invite to the groups.
101
+ * @param search
102
+ * @param config
103
+ */
104
+ static getGroupsSuggestedUsers(search, config) {
105
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetGroupsSuggestedUsers.url({ search }), method: Endpoints.GetGroupsSuggestedUsers.method }));
106
+ }
107
+ /**
108
+ * This endpoint returns a list of invited users.
109
+ * @param id
110
+ * @param config
111
+ */
112
+ static getGroupInvitedUsers(id, config) {
113
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetGroupInvitedUsers.url({ id }), method: Endpoints.GetGroupInvitedUsers.method }));
114
+ }
115
+ /**
116
+ * This endpoint subscribes to a group.
117
+ * @param id
118
+ * @param config
119
+ */
120
+ static subscribeToGroup(id, config) {
121
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.SubscribeToGroup.url({ id }), method: Endpoints.SubscribeToGroup.method }));
122
+ }
123
+ /**
124
+ * This endpoint unsubscribes from a group.
125
+ * @param id
126
+ * @param config
127
+ */
128
+ static unsubscribeFromGroup(id, config) {
129
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.UnsubscribeFromGroup.url({ id }), method: Endpoints.UnsubscribeFromGroup.method }));
130
+ }
131
+ /**
132
+ * This endpoint allows to invite or accept a group invite.
133
+ * @param id
134
+ * @param data
135
+ * @param config
136
+ */
137
+ static inviteOrAcceptGroupRequest(id, data, config) {
138
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.InviteOrAcceptGroupRequest.url({ id }), method: Endpoints.InviteOrAcceptGroupRequest.method, data: data }));
139
+ }
140
+ /**
141
+ * This endpoint retrieves the group subscription status.
142
+ * @param id
143
+ * @param config
144
+ */
145
+ static getGroupSubscriptionStatus(id, config) {
146
+ return apiRequest(Object.assign(Object.assign({}, config), { url: Endpoints.GetGroupSubscriptionStatus.url({ id }), method: Endpoints.GetGroupSubscriptionStatus.method }));
147
+ }
148
+ /**
149
+ * This endpoint returns a list of the users waiting to be added to the group.
150
+ * @param id
151
+ * @param params
152
+ * @param config
153
+ */
154
+ static getGroupWaitingApprovalSubscribers(id, params, config) {
155
+ const p = urlParams(params);
156
+ return apiRequest(Object.assign(Object.assign({}, config), { url: `${Endpoints.GetGroupWaitingApprovalSubscribers.url({ id })}?${p.toString()}`, method: Endpoints.GetGroupWaitingApprovalSubscribers.method }));
157
+ }
158
+ }
159
+ /**
160
+ *
161
+ :::tip Incubator service can be used in the following way:
162
+
163
+ ```jsx
164
+ 1. Import the service from our library:
165
+
166
+ import {GroupService} from "@selfcommunity/api-services";
167
+ ```
168
+ ```jsx
169
+ 2. Create a function and put the service inside it!
170
+ The async function `searchGroups` will return the groups matching the search query.
171
+
172
+ async searchGroups() {
173
+ return await GroupService.searchGroups();
174
+ }
175
+ ```
176
+ ```jsx
177
+ In case of required `params`, just add them inside the brackets.
178
+
179
+ async getSpecificGroupInfo(groupId) {
180
+ return await GroupService.getSpecificGroupInfo(groupId);
181
+ }
182
+ ```
183
+ ```jsx
184
+ If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
185
+
186
+ 1. Declare it(or declare them, it is possible to add multiple params)
187
+
188
+ const headers = headers: {Authorization: `Bearer ${yourToken}`}
189
+
190
+ 2. Add it inside the brackets and pass it to the function, as shown in the previous example!
191
+ ```
192
+ :::
193
+ */
194
+ export default class GroupService {
195
+ static getUserGroups(params, config) {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ return GroupApiClient.getUserGroups(params, config);
198
+ });
199
+ }
200
+ static searchGroups(params, config) {
201
+ return __awaiter(this, void 0, void 0, function* () {
202
+ return GroupApiClient.searchGroups(params, config);
203
+ });
204
+ }
205
+ static getSpecificGroupInfo(id, config) {
206
+ return __awaiter(this, void 0, void 0, function* () {
207
+ return GroupApiClient.getSpecificGroupInfo(id, config);
208
+ });
209
+ }
210
+ static getGroupFeed(id, params, config) {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ return GroupApiClient.getGroupFeed(id, params, config);
213
+ });
214
+ }
215
+ static createGroup(data, config) {
216
+ return __awaiter(this, void 0, void 0, function* () {
217
+ return GroupApiClient.createGroup(data, config);
218
+ });
219
+ }
220
+ static updateGroup(id, data, config) {
221
+ return __awaiter(this, void 0, void 0, function* () {
222
+ return GroupApiClient.updateGroup(id, data, config);
223
+ });
224
+ }
225
+ static patchGroup(id, data, config) {
226
+ return __awaiter(this, void 0, void 0, function* () {
227
+ return GroupApiClient.patchGroup(id, data, config);
228
+ });
229
+ }
230
+ static changeGroupAvatarOrCover(id, data, config) {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ return GroupApiClient.changeGroupAvatarOrCover(id, data, config);
233
+ });
234
+ }
235
+ static getGroupMembers(id, params, config) {
236
+ return __awaiter(this, void 0, void 0, function* () {
237
+ return GroupApiClient.getGroupMembers(id, params, config);
238
+ });
239
+ }
240
+ static getGroupSuggestedUsers(id, search, config) {
241
+ return __awaiter(this, void 0, void 0, function* () {
242
+ return GroupApiClient.getGroupSuggestedUsers(id, search, config);
243
+ });
244
+ }
245
+ static getGroupsSuggestedUsers(search, config) {
246
+ return __awaiter(this, void 0, void 0, function* () {
247
+ return GroupApiClient.getGroupsSuggestedUsers(search, config);
248
+ });
249
+ }
250
+ static getGroupInvitedUsers(id, config) {
251
+ return __awaiter(this, void 0, void 0, function* () {
252
+ return GroupApiClient.getGroupInvitedUsers(id, config);
253
+ });
254
+ }
255
+ static subscribeToGroup(id, config) {
256
+ return __awaiter(this, void 0, void 0, function* () {
257
+ return GroupApiClient.subscribeToGroup(id, config);
258
+ });
259
+ }
260
+ static unsubscribeFromGroup(id, config) {
261
+ return __awaiter(this, void 0, void 0, function* () {
262
+ return GroupApiClient.unsubscribeFromGroup(id, config);
263
+ });
264
+ }
265
+ static inviteOrAcceptGroupRequest(id, data, config) {
266
+ return __awaiter(this, void 0, void 0, function* () {
267
+ return GroupApiClient.inviteOrAcceptGroupRequest(id, data, config);
268
+ });
269
+ }
270
+ static getGroupSubscriptionStatus(id, config) {
271
+ return __awaiter(this, void 0, void 0, function* () {
272
+ return GroupApiClient.getGroupSubscriptionStatus(id, config);
273
+ });
274
+ }
275
+ static getGroupWaitingApprovalSubscribers(id, params, config) {
276
+ return __awaiter(this, void 0, void 0, function* () {
277
+ return GroupApiClient.getGroupWaitingApprovalSubscribers(id, params, config);
278
+ });
279
+ }
280
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * GroupCreateParams interface
3
+ */
4
+ import { SCGroupPrivacyType } from '@selfcommunity/types';
5
+ import { BaseGetParams } from './baseParams';
6
+ export interface GroupCreateParams {
7
+ /**
8
+ * A unique name for the group
9
+ */
10
+ name: string;
11
+ /**
12
+ * The group privacy
13
+ */
14
+ privacy: SCGroupPrivacyType;
15
+ /**
16
+ * The group visibility. It is required when privacy = private.
17
+ */
18
+ visible?: boolean;
19
+ /**
20
+ * The group description
21
+ */
22
+ description?: string;
23
+ /**
24
+ * The users to invite to the group
25
+ */
26
+ invite_users?: number[];
27
+ }
28
+ /**
29
+ * GroupFeedParams interface.
30
+ */
31
+ export interface GroupFeedParams extends BaseGetParams {
32
+ /**
33
+ * Which field to use when ordering the results.
34
+ */
35
+ ordering?: string;
36
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -23,4 +23,5 @@ import { FeatureParams } from './feature';
23
23
  import { ScoreParams } from './score';
24
24
  import { InsightCommonParams, InsightEmbedParams, InsightUserParams, InsightContributionParams } from './insight';
25
25
  import { ReactionParams } from './reaction';
26
- export { AccountCreateParams, AccountVerifyParams, AccountRecoverParams, AccountResetParams, AccountSearchParams, SCPaginatedResponse, WebhookParamType, WebhookEventsType, SSOSignUpParams, CommentListParams, CommentCreateParams, IncubatorCreateParams, IncubatorSearchParams, LoyaltyPrizeParams, LoyaltyGetPrizeParams, ModerationParams, ModerateContributionParams, FlaggedContributionParams, CustomNotificationParams, UserGetParams, UserAutocompleteParams, UserScoreParams, UserSearchParams, TagParams, TagGetParams, MediaCreateParams, MediaTypes, ChunkUploadCompleteParams, ChunkUploadParams, ThreadParams, ThreadDeleteParams, MessageCreateParams, MessageMediaUploadParams, MessageThumbnailUploadParams, MessageChunkUploadDoneParams, MessageMediaChunksParams, CategoryParams, CustomAdvParams, CustomPageParams, CustomPageSearchParams, EmbedUpdateParams, EmbedSearchParams, BaseGetParams, BaseSearchParams, FeedObjGetParams, FeedObjCreateParams, FeedObjectPollVotesSearch, FeedParams, LegalPageFilterParams, FeatureParams, ScoreParams, InsightContributionParams, InsightUserParams, InsightEmbedParams, InsightCommonParams, ReactionParams };
26
+ import { GroupCreateParams, GroupFeedParams } from './group';
27
+ export { AccountCreateParams, AccountVerifyParams, AccountRecoverParams, AccountResetParams, AccountSearchParams, SCPaginatedResponse, WebhookParamType, WebhookEventsType, SSOSignUpParams, CommentListParams, CommentCreateParams, IncubatorCreateParams, IncubatorSearchParams, LoyaltyPrizeParams, LoyaltyGetPrizeParams, ModerationParams, ModerateContributionParams, FlaggedContributionParams, CustomNotificationParams, UserGetParams, UserAutocompleteParams, UserScoreParams, UserSearchParams, TagParams, TagGetParams, MediaCreateParams, MediaTypes, ChunkUploadCompleteParams, ChunkUploadParams, ThreadParams, ThreadDeleteParams, MessageCreateParams, MessageMediaUploadParams, MessageThumbnailUploadParams, MessageChunkUploadDoneParams, MessageMediaChunksParams, CategoryParams, CustomAdvParams, CustomPageParams, CustomPageSearchParams, EmbedUpdateParams, EmbedSearchParams, BaseGetParams, BaseSearchParams, FeedObjGetParams, FeedObjCreateParams, FeedObjectPollVotesSearch, FeedParams, LegalPageFilterParams, FeatureParams, ScoreParams, InsightContributionParams, InsightUserParams, InsightEmbedParams, InsightCommonParams, ReactionParams, GroupCreateParams, GroupFeedParams };