@selfcommunity/api-services 0.4.9-alpha.0 → 0.4.9-alpha.10

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.
@@ -1121,6 +1121,77 @@ const Endpoints = {
1121
1121
  GetSpecificReaction: {
1122
1122
  url: (0, utils_1.urlReplacer)('/api/v2/reaction/$(id)/'),
1123
1123
  method: 'GET'
1124
+ },
1125
+ /**
1126
+ * Groups
1127
+ */
1128
+ GetUserGroups: {
1129
+ url: (0, utils_1.urlReplacer)('/api/v2/group/'),
1130
+ method: 'GET'
1131
+ },
1132
+ GetGroupInfo: {
1133
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/'),
1134
+ method: 'GET'
1135
+ },
1136
+ GetGroupFeed: {
1137
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/feed/'),
1138
+ method: 'GET'
1139
+ },
1140
+ SearchGroups: {
1141
+ url: (0, utils_1.urlReplacer)('/api/v2/group/search/'),
1142
+ method: 'GET'
1143
+ },
1144
+ CreateGroup: {
1145
+ url: (0, utils_1.urlReplacer)('/api/v2/group/'),
1146
+ method: 'POST'
1147
+ },
1148
+ UpdateGroup: {
1149
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/'),
1150
+ method: 'PUT'
1151
+ },
1152
+ PatchGroup: {
1153
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/'),
1154
+ method: 'PATCH'
1155
+ },
1156
+ GetGroupSuggestedUsers: {
1157
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/user/?search=$(search)'),
1158
+ method: 'GET'
1159
+ },
1160
+ GetGroupsSuggestedUsers: {
1161
+ url: (0, utils_1.urlReplacer)('/api/v2/group/user/?search=$(search)'),
1162
+ method: 'GET'
1163
+ },
1164
+ InviteOrAcceptGroupRequest: {
1165
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/invite/'),
1166
+ method: 'POST'
1167
+ },
1168
+ GetGroupInvitedUsers: {
1169
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/invite/'),
1170
+ method: 'GET'
1171
+ },
1172
+ GetGroupSubscriptionStatus: {
1173
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/status/'),
1174
+ method: 'GET'
1175
+ },
1176
+ SubscribeToGroup: {
1177
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/subscribe/'),
1178
+ method: 'POST'
1179
+ },
1180
+ GetGroupSubscribers: {
1181
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/subscribe/'),
1182
+ method: 'GET'
1183
+ },
1184
+ GetGroupWaitingApprovalSubscribers: {
1185
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/request_subscribe/'),
1186
+ method: 'GET'
1187
+ },
1188
+ UnsubscribeFromGroup: {
1189
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/subscribe/'),
1190
+ method: 'DELETE'
1191
+ },
1192
+ RemoveUserFromGroup: {
1193
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/subscribe/?user=$(user)'),
1194
+ method: 'DELETE'
1124
1195
  }
1125
1196
  };
1126
1197
  exports.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/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ModerationService = exports.MediaApiClient = exports.MediaService = exports.LoyaltyApiClient = exports.LoyaltyService = exports.LocalityApiClient = exports.LocalityService = exports.LegalPageApiClient = exports.LegalPageService = exports.InviteApiClient = exports.InviteService = exports.InsightApiClient = exports.InsightService = exports.IncubatorApiClient = exports.IncubatorService = exports.FeedObjectApiClient = exports.FeedObjectService = exports.FeedApiClient = exports.FeedService = exports.EmbedApiClient = exports.EmbedService = exports.DataPortabilityApiClient = exports.DataPortabilityService = exports.CustomPageApiClient = exports.CustomPageService = exports.CustomMenuApiClient = exports.CustomMenuService = exports.CustomAdvApiClient = exports.CustomAdvService = exports.CommentApiClient = exports.CommentService = exports.CategoryApiClient = exports.CategoryService = exports.FeatureApiClient = exports.FeatureService = exports.UserApiClient = exports.UserService = exports.PreferenceApiClient = exports.PreferenceService = exports.AccountApiClient = exports.AccountService = exports.Endpoints = exports.urlParams = exports.parseJwt = exports.generateJWTToken = exports.getCancelTokenSourceRequest = exports.formatHttpErrorCode = exports.formatHttpError = exports.apiRequest = exports.http = void 0;
4
- exports.ReactionApiClient = exports.ReactionService = exports.MediaTypes = exports.WebhookApiClient = exports.WebhookService = exports.TagApiClient = exports.TagService = exports.SuggestionApiClient = exports.SuggestionService = exports.SSOApiClient = exports.SSOService = exports.ScoreApiClient = exports.ScoreService = exports.PromoApiClient = exports.PromoService = exports.PrivateMessageApiClient = exports.PrivateMessageService = exports.NotificationApiClient = exports.NotificationService = exports.ModerationApiClient = void 0;
4
+ exports.GroupApiClient = exports.GroupService = exports.ReactionApiClient = exports.ReactionService = exports.MediaTypes = exports.WebhookApiClient = exports.WebhookService = exports.TagApiClient = exports.TagService = exports.SuggestionApiClient = exports.SuggestionService = exports.SSOApiClient = exports.SSOService = exports.ScoreApiClient = exports.ScoreService = exports.PromoApiClient = exports.PromoService = exports.PrivateMessageApiClient = exports.PrivateMessageService = exports.NotificationApiClient = exports.NotificationService = exports.ModerationApiClient = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  /**
7
7
  * Axios client wrapper
@@ -120,6 +120,9 @@ Object.defineProperty(exports, "WebhookApiClient", { enumerable: true, get: func
120
120
  const reactions_1 = tslib_1.__importStar(require("./services/reactions"));
121
121
  exports.ReactionService = reactions_1.default;
122
122
  Object.defineProperty(exports, "ReactionApiClient", { enumerable: true, get: function () { return reactions_1.ReactionApiClient; } });
123
+ const group_1 = tslib_1.__importStar(require("./services/group"));
124
+ exports.GroupService = group_1.default;
125
+ Object.defineProperty(exports, "GroupApiClient", { enumerable: true, get: function () { return group_1.GroupApiClient; } });
123
126
  /**
124
127
  * Types
125
128
  */
@@ -0,0 +1,207 @@
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
+ removeUserFromGroup(id: number | string, user: number | string, config?: AxiosRequestConfig): Promise<any>;
18
+ getGroupInvitedUsers(id: number | string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
19
+ subscribeToGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
20
+ unsubscribeFromGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
21
+ inviteOrAcceptGroupRequest(id: number | string, data: {
22
+ users: number[];
23
+ }, config?: AxiosRequestConfig): Promise<any>;
24
+ getGroupSubscriptionStatus(id: number | string, config?: AxiosRequestConfig): Promise<any>;
25
+ getGroupWaitingApprovalSubscribers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
26
+ }
27
+ /**
28
+ * Contains all the endpoints needed to manage groups.
29
+ */
30
+ export declare class GroupApiClient {
31
+ /**
32
+ * This endpoint retrieves all the groups of the logged-in user.
33
+ * @param params
34
+ * @param config
35
+ */
36
+ static getUserGroups(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
37
+ /**
38
+ * This endpoint performs groups search
39
+ * @param params
40
+ * @param config
41
+ */
42
+ static searchGroups(params?: BaseSearchParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
43
+ /**
44
+ * This endpoint retrieves a specific group.
45
+ * @param id
46
+ * @param config
47
+ */
48
+ static getSpecificGroupInfo(id: number | string, config?: AxiosRequestConfig): Promise<SCGroupType>;
49
+ /**
50
+ * This endpoint performs groups search
51
+ * @param id
52
+ * @param params
53
+ * @param config
54
+ */
55
+ static getGroupFeed(id: number | string, params?: GroupFeedParams, config?: AxiosRequestConfig): Promise<any>;
56
+ /**
57
+ * This endpoint creates a group.
58
+ * @param data
59
+ * @param config
60
+ */
61
+ static createGroup(data: GroupCreateParams | FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
62
+ /**
63
+ * This endpoint updates a group.
64
+ * @param id
65
+ * @param data
66
+ * @param config
67
+ */
68
+ static updateGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
69
+ /**
70
+ * This endpoint patches a group.
71
+ * @param id
72
+ * @param data
73
+ * @param config
74
+ */
75
+ static patchGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
76
+ /**
77
+ * This endpoint changes the group avatar
78
+ * @param id
79
+ * @param data
80
+ * @param config
81
+ */
82
+ static changeGroupAvatarOrCover(id: number | string, data: FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
83
+ /**
84
+ * This endpoint returns all subscribers of a specific group.
85
+ * @param id
86
+ * @param params
87
+ * @param config
88
+ */
89
+ static getGroupMembers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
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: number | string, search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
97
+ /**
98
+ * This endpoint returns a list of suggested users to invite to the groups.
99
+ * @param search
100
+ * @param config
101
+ */
102
+ static getGroupsSuggestedUsers(search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
103
+ /**
104
+ * This endpoint removes the user specified from the group.
105
+ * @param id
106
+ * @param user
107
+ * @param config
108
+ */
109
+ static removeUserFromGroup(id: number | string, user: number | string, config?: AxiosRequestConfig): Promise<any>;
110
+ /**
111
+ * This endpoint returns a list of invited users.
112
+ * @param id
113
+ * @param config
114
+ */
115
+ static getGroupInvitedUsers(id: number | string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
116
+ /**
117
+ * This endpoint subscribes to a group.
118
+ * @param id
119
+ * @param config
120
+ */
121
+ static subscribeToGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
122
+ /**
123
+ * This endpoint unsubscribes from a group.
124
+ * @param id
125
+ * @param config
126
+ */
127
+ static unsubscribeFromGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
128
+ /**
129
+ * This endpoint allows to invite or accept a group invite.
130
+ * @param id
131
+ * @param data
132
+ * @param config
133
+ */
134
+ static inviteOrAcceptGroupRequest(id: number | string, data: {
135
+ users: number[];
136
+ }, config?: AxiosRequestConfig): Promise<any>;
137
+ /**
138
+ * This endpoint retrieves the group subscription status.
139
+ * @param id
140
+ * @param config
141
+ */
142
+ static getGroupSubscriptionStatus(id: number | string, config?: AxiosRequestConfig): Promise<any>;
143
+ /**
144
+ * This endpoint returns a list of the users waiting to be added to the group.
145
+ * @param id
146
+ * @param params
147
+ * @param config
148
+ */
149
+ static getGroupWaitingApprovalSubscribers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
150
+ }
151
+ /**
152
+ *
153
+ :::tip Incubator service can be used in the following way:
154
+
155
+ ```jsx
156
+ 1. Import the service from our library:
157
+
158
+ import {GroupService} from "@selfcommunity/api-services";
159
+ ```
160
+ ```jsx
161
+ 2. Create a function and put the service inside it!
162
+ The async function `searchGroups` will return the groups matching the search query.
163
+
164
+ async searchGroups() {
165
+ return await GroupService.searchGroups();
166
+ }
167
+ ```
168
+ ```jsx
169
+ In case of required `params`, just add them inside the brackets.
170
+
171
+ async getSpecificGroupInfo(groupId) {
172
+ return await GroupService.getSpecificGroupInfo(groupId);
173
+ }
174
+ ```
175
+ ```jsx
176
+ If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
177
+
178
+ 1. Declare it(or declare them, it is possible to add multiple params)
179
+
180
+ const headers = headers: {Authorization: `Bearer ${yourToken}`}
181
+
182
+ 2. Add it inside the brackets and pass it to the function, as shown in the previous example!
183
+ ```
184
+ :::
185
+ */
186
+ export default class GroupService {
187
+ static getUserGroups(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
188
+ static searchGroups(params?: BaseSearchParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
189
+ static getSpecificGroupInfo(id: number | string, config?: AxiosRequestConfig): Promise<SCGroupType>;
190
+ static getGroupFeed(id: number | string, params?: GroupFeedParams, config?: AxiosRequestConfig): Promise<any>;
191
+ static createGroup(data: GroupCreateParams | FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
192
+ static updateGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
193
+ static patchGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
194
+ static changeGroupAvatarOrCover(id: number | string, data: FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
195
+ static getGroupMembers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
196
+ static getGroupSuggestedUsers(id: number | string, search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
197
+ static getGroupsSuggestedUsers(search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
198
+ static removeUserFromGroup(id: number | string, user: number | string, config?: AxiosRequestConfig): Promise<any>;
199
+ static getGroupInvitedUsers(id: number | string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
200
+ static subscribeToGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
201
+ static unsubscribeFromGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
202
+ static inviteOrAcceptGroupRequest(id: number | string, data: {
203
+ users: number[];
204
+ }, config?: AxiosRequestConfig): Promise<any>;
205
+ static getGroupSubscriptionStatus(id: number | string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<any>>;
206
+ static getGroupWaitingApprovalSubscribers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
207
+ }
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupApiClient = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const apiRequest_1 = require("../../utils/apiRequest");
6
+ const Endpoints_1 = tslib_1.__importDefault(require("../../constants/Endpoints"));
7
+ const url_1 = require("../../utils/url");
8
+ /**
9
+ * Contains all the endpoints needed to manage groups.
10
+ */
11
+ class GroupApiClient {
12
+ /**
13
+ * This endpoint retrieves all the groups of the logged-in user.
14
+ * @param params
15
+ * @param config
16
+ */
17
+ static getUserGroups(params, config) {
18
+ const p = (0, url_1.urlParams)(params);
19
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.GetUserGroups.url({})}?${p.toString()}`, method: Endpoints_1.default.GetUserGroups.method }));
20
+ }
21
+ /**
22
+ * This endpoint performs groups search
23
+ * @param params
24
+ * @param config
25
+ */
26
+ static searchGroups(params, config) {
27
+ const p = (0, url_1.urlParams)(params);
28
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.SearchGroups.url({})}?${p.toString()}`, method: Endpoints_1.default.SearchGroups.method }));
29
+ }
30
+ /**
31
+ * This endpoint retrieves a specific group.
32
+ * @param id
33
+ * @param config
34
+ */
35
+ static getSpecificGroupInfo(id, config) {
36
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.GetGroupInfo.url({ id }), method: Endpoints_1.default.GetGroupInfo.method }));
37
+ }
38
+ /**
39
+ * This endpoint performs groups search
40
+ * @param id
41
+ * @param params
42
+ * @param config
43
+ */
44
+ static getGroupFeed(id, params, config) {
45
+ const p = (0, url_1.urlParams)(params);
46
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.GetGroupFeed.url({ id })}?${p.toString()}`, method: Endpoints_1.default.GetGroupFeed.method }));
47
+ }
48
+ /**
49
+ * This endpoint creates a group.
50
+ * @param data
51
+ * @param config
52
+ */
53
+ static createGroup(data, config) {
54
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.CreateGroup.url({}), method: Endpoints_1.default.CreateGroup.method, data: data }));
55
+ }
56
+ /**
57
+ * This endpoint updates a group.
58
+ * @param id
59
+ * @param data
60
+ * @param config
61
+ */
62
+ static updateGroup(id, data, config) {
63
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.UpdateGroup.url({ id }), method: Endpoints_1.default.UpdateGroup.method, data: data }));
64
+ }
65
+ /**
66
+ * This endpoint patches a group.
67
+ * @param id
68
+ * @param data
69
+ * @param config
70
+ */
71
+ static patchGroup(id, data, config) {
72
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.PatchGroup.url({ id }), method: Endpoints_1.default.PatchGroup.method, data: data }));
73
+ }
74
+ /**
75
+ * This endpoint changes the group avatar
76
+ * @param id
77
+ * @param data
78
+ * @param config
79
+ */
80
+ static changeGroupAvatarOrCover(id, data, config) {
81
+ return (0, apiRequest_1.apiRequest)(Object.assign({ url: Endpoints_1.default.PatchGroup.url({ id }), method: Endpoints_1.default.PatchGroup.method, data }, config));
82
+ }
83
+ /**
84
+ * This endpoint returns all subscribers of a specific group.
85
+ * @param id
86
+ * @param params
87
+ * @param config
88
+ */
89
+ static getGroupMembers(id, params, config) {
90
+ const p = (0, url_1.urlParams)(params);
91
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.GetGroupSubscribers.url({ id })}?${p.toString()}`, method: Endpoints_1.default.GetGroupSubscribers.method }));
92
+ }
93
+ /**
94
+ * This endpoint returns a list of suggested users to invite to the group.
95
+ * @param id
96
+ * @param search
97
+ * @param config
98
+ */
99
+ static getGroupSuggestedUsers(id, search, config) {
100
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.GetGroupSuggestedUsers.url({ id, search }), method: Endpoints_1.default.GetGroupSuggestedUsers.method }));
101
+ }
102
+ /**
103
+ * This endpoint returns a list of suggested users to invite to the groups.
104
+ * @param search
105
+ * @param config
106
+ */
107
+ static getGroupsSuggestedUsers(search, config) {
108
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.GetGroupsSuggestedUsers.url({ search }), method: Endpoints_1.default.GetGroupsSuggestedUsers.method }));
109
+ }
110
+ /**
111
+ * This endpoint removes the user specified from the group.
112
+ * @param id
113
+ * @param user
114
+ * @param config
115
+ */
116
+ static removeUserFromGroup(id, user, config) {
117
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.RemoveUserFromGroup.url({ id, user }), method: Endpoints_1.default.RemoveUserFromGroup.method }));
118
+ }
119
+ /**
120
+ * This endpoint returns a list of invited users.
121
+ * @param id
122
+ * @param config
123
+ */
124
+ static getGroupInvitedUsers(id, config) {
125
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.GetGroupInvitedUsers.url({ id }), method: Endpoints_1.default.GetGroupInvitedUsers.method }));
126
+ }
127
+ /**
128
+ * This endpoint subscribes to a group.
129
+ * @param id
130
+ * @param config
131
+ */
132
+ static subscribeToGroup(id, config) {
133
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.SubscribeToGroup.url({ id }), method: Endpoints_1.default.SubscribeToGroup.method }));
134
+ }
135
+ /**
136
+ * This endpoint unsubscribes from a group.
137
+ * @param id
138
+ * @param config
139
+ */
140
+ static unsubscribeFromGroup(id, config) {
141
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.UnsubscribeFromGroup.url({ id }), method: Endpoints_1.default.UnsubscribeFromGroup.method }));
142
+ }
143
+ /**
144
+ * This endpoint allows to invite or accept a group invite.
145
+ * @param id
146
+ * @param data
147
+ * @param config
148
+ */
149
+ static inviteOrAcceptGroupRequest(id, data, config) {
150
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.InviteOrAcceptGroupRequest.url({ id }), method: Endpoints_1.default.InviteOrAcceptGroupRequest.method, data: data }));
151
+ }
152
+ /**
153
+ * This endpoint retrieves the group subscription status.
154
+ * @param id
155
+ * @param config
156
+ */
157
+ static getGroupSubscriptionStatus(id, config) {
158
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.GetGroupSubscriptionStatus.url({ id }), method: Endpoints_1.default.GetGroupSubscriptionStatus.method }));
159
+ }
160
+ /**
161
+ * This endpoint returns a list of the users waiting to be added to the group.
162
+ * @param id
163
+ * @param params
164
+ * @param config
165
+ */
166
+ static getGroupWaitingApprovalSubscribers(id, params, config) {
167
+ const p = (0, url_1.urlParams)(params);
168
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.GetGroupWaitingApprovalSubscribers.url({ id })}?${p.toString()}`, method: Endpoints_1.default.GetGroupWaitingApprovalSubscribers.method }));
169
+ }
170
+ }
171
+ exports.GroupApiClient = GroupApiClient;
172
+ /**
173
+ *
174
+ :::tip Incubator service can be used in the following way:
175
+
176
+ ```jsx
177
+ 1. Import the service from our library:
178
+
179
+ import {GroupService} from "@selfcommunity/api-services";
180
+ ```
181
+ ```jsx
182
+ 2. Create a function and put the service inside it!
183
+ The async function `searchGroups` will return the groups matching the search query.
184
+
185
+ async searchGroups() {
186
+ return await GroupService.searchGroups();
187
+ }
188
+ ```
189
+ ```jsx
190
+ In case of required `params`, just add them inside the brackets.
191
+
192
+ async getSpecificGroupInfo(groupId) {
193
+ return await GroupService.getSpecificGroupInfo(groupId);
194
+ }
195
+ ```
196
+ ```jsx
197
+ If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
198
+
199
+ 1. Declare it(or declare them, it is possible to add multiple params)
200
+
201
+ const headers = headers: {Authorization: `Bearer ${yourToken}`}
202
+
203
+ 2. Add it inside the brackets and pass it to the function, as shown in the previous example!
204
+ ```
205
+ :::
206
+ */
207
+ class GroupService {
208
+ static getUserGroups(params, config) {
209
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
210
+ return GroupApiClient.getUserGroups(params, config);
211
+ });
212
+ }
213
+ static searchGroups(params, config) {
214
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
215
+ return GroupApiClient.searchGroups(params, config);
216
+ });
217
+ }
218
+ static getSpecificGroupInfo(id, config) {
219
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
220
+ return GroupApiClient.getSpecificGroupInfo(id, config);
221
+ });
222
+ }
223
+ static getGroupFeed(id, params, config) {
224
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
225
+ return GroupApiClient.getGroupFeed(id, params, config);
226
+ });
227
+ }
228
+ static createGroup(data, config) {
229
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
230
+ return GroupApiClient.createGroup(data, config);
231
+ });
232
+ }
233
+ static updateGroup(id, data, config) {
234
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
235
+ return GroupApiClient.updateGroup(id, data, config);
236
+ });
237
+ }
238
+ static patchGroup(id, data, config) {
239
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
240
+ return GroupApiClient.patchGroup(id, data, config);
241
+ });
242
+ }
243
+ static changeGroupAvatarOrCover(id, data, config) {
244
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
245
+ return GroupApiClient.changeGroupAvatarOrCover(id, data, config);
246
+ });
247
+ }
248
+ static getGroupMembers(id, params, config) {
249
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
250
+ return GroupApiClient.getGroupMembers(id, params, config);
251
+ });
252
+ }
253
+ static getGroupSuggestedUsers(id, search, config) {
254
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
255
+ return GroupApiClient.getGroupSuggestedUsers(id, search, config);
256
+ });
257
+ }
258
+ static getGroupsSuggestedUsers(search, config) {
259
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
260
+ return GroupApiClient.getGroupsSuggestedUsers(search, config);
261
+ });
262
+ }
263
+ static removeUserFromGroup(id, user, config) {
264
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
265
+ return GroupApiClient.removeUserFromGroup(id, user, config);
266
+ });
267
+ }
268
+ static getGroupInvitedUsers(id, config) {
269
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
270
+ return GroupApiClient.getGroupInvitedUsers(id, config);
271
+ });
272
+ }
273
+ static subscribeToGroup(id, config) {
274
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
275
+ return GroupApiClient.subscribeToGroup(id, config);
276
+ });
277
+ }
278
+ static unsubscribeFromGroup(id, config) {
279
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
280
+ return GroupApiClient.unsubscribeFromGroup(id, config);
281
+ });
282
+ }
283
+ static inviteOrAcceptGroupRequest(id, data, config) {
284
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
285
+ return GroupApiClient.inviteOrAcceptGroupRequest(id, data, config);
286
+ });
287
+ }
288
+ static getGroupSubscriptionStatus(id, config) {
289
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
290
+ return GroupApiClient.getGroupSubscriptionStatus(id, config);
291
+ });
292
+ }
293
+ static getGroupWaitingApprovalSubscribers(id, params, config) {
294
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
295
+ return GroupApiClient.getGroupWaitingApprovalSubscribers(id, params, config);
296
+ });
297
+ }
298
+ }
299
+ exports.default = GroupService;
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });