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

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
+ GetAllGroups: {
1141
+ url: (0, utils_1.urlReplacer)('/api/v2/group/'),
1142
+ method: 'GET'
1143
+ },
1144
+ SearchGroups: {
1145
+ url: (0, utils_1.urlReplacer)('/api/v2/group/search/'),
1146
+ method: 'GET'
1147
+ },
1148
+ CreateGroup: {
1149
+ url: (0, utils_1.urlReplacer)('/api/v2/group/'),
1150
+ method: 'POST'
1151
+ },
1152
+ UpdateGroup: {
1153
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/'),
1154
+ method: 'PUT'
1155
+ },
1156
+ PatchGroup: {
1157
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/'),
1158
+ method: 'PATCH'
1159
+ },
1160
+ GetGroupSuggestedUsers: {
1161
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/user/?search=$(search)'),
1162
+ method: 'GET'
1163
+ },
1164
+ GetGroupsSuggestedUsers: {
1165
+ url: (0, utils_1.urlReplacer)('/api/v2/group/user/?search=$(search)'),
1166
+ method: 'GET'
1167
+ },
1168
+ InviteOrAcceptGroupRequest: {
1169
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/invite/'),
1170
+ method: 'POST'
1171
+ },
1172
+ GetGroupInvitedUsers: {
1173
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/invite/'),
1174
+ method: 'GET'
1175
+ },
1176
+ GetGroupSubscriptionStatus: {
1177
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/status/'),
1178
+ method: 'GET'
1179
+ },
1180
+ SubscribeToGroup: {
1181
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/subscribe/'),
1182
+ method: 'POST'
1183
+ },
1184
+ GetGroupSubscribers: {
1185
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/subscribe/'),
1186
+ method: 'GET'
1187
+ },
1188
+ GetGroupWaitingApprovalSubscribers: {
1189
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/request_subscribe/'),
1190
+ method: 'GET'
1191
+ },
1192
+ UnsubscribeFromGroup: {
1193
+ url: (0, utils_1.urlReplacer)('/api/v2/group/$(id)/subscribe/'),
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,206 @@
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
+ getAllGroups(params?: BaseSearchParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
8
+ searchGroups(params?: BaseSearchParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
9
+ getSpecificGroupInfo(id: number | string, config?: AxiosRequestConfig): Promise<SCGroupType>;
10
+ getGroupFeed(id: number | string, params?: GroupFeedParams, config?: AxiosRequestConfig): Promise<any>;
11
+ createGroup(data: GroupCreateParams | FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
12
+ updateGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
13
+ patchGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
14
+ changeGroupAvatarOrCover(id: number | string, data: FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
15
+ getGroupMembers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
16
+ getGroupSuggestedUsers(id: number | string, search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
17
+ getGroupsSuggestedUsers(search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
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 getAllGroups(params?: BaseSearchParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
43
+ /**
44
+ * This endpoint performs groups search
45
+ * @param params
46
+ * @param config
47
+ */
48
+ static searchGroups(params?: BaseSearchParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
49
+ /**
50
+ * This endpoint retrieves a specific group.
51
+ * @param id
52
+ * @param config
53
+ */
54
+ static getSpecificGroupInfo(id: number | string, config?: AxiosRequestConfig): Promise<SCGroupType>;
55
+ /**
56
+ * This endpoint performs groups search
57
+ * @param id
58
+ * @param params
59
+ * @param config
60
+ */
61
+ static getGroupFeed(id: number | string, params?: GroupFeedParams, config?: AxiosRequestConfig): Promise<any>;
62
+ /**
63
+ * This endpoint creates a group.
64
+ * @param data
65
+ * @param config
66
+ */
67
+ static createGroup(data: GroupCreateParams | FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
68
+ /**
69
+ * This endpoint updates a group.
70
+ * @param id
71
+ * @param data
72
+ * @param config
73
+ */
74
+ static updateGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
75
+ /**
76
+ * This endpoint patches a group.
77
+ * @param id
78
+ * @param data
79
+ * @param config
80
+ */
81
+ static patchGroup(id: number | string, data: SCGroupType, config?: AxiosRequestConfig): Promise<SCGroupType>;
82
+ /**
83
+ * This endpoint changes the group avatar
84
+ * @param id
85
+ * @param data
86
+ * @param config
87
+ */
88
+ static changeGroupAvatarOrCover(id: number | string, data: FormData, config?: AxiosRequestConfig): Promise<SCGroupType>;
89
+ /**
90
+ * This endpoint returns all subscribers of a specific group.
91
+ * @param id
92
+ * @param params
93
+ * @param config
94
+ */
95
+ static getGroupMembers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
96
+ /**
97
+ * This endpoint returns a list of suggested users to invite to the group.
98
+ * @param id
99
+ * @param search
100
+ * @param config
101
+ */
102
+ static getGroupSuggestedUsers(id: number | string, search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
103
+ /**
104
+ * This endpoint returns a list of suggested users to invite to the groups.
105
+ * @param search
106
+ * @param config
107
+ */
108
+ static getGroupsSuggestedUsers(search: string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
109
+ /**
110
+ * This endpoint returns a list of invited users.
111
+ * @param id
112
+ * @param config
113
+ */
114
+ static getGroupInvitedUsers(id: number | string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
115
+ /**
116
+ * This endpoint subscribes to a group.
117
+ * @param id
118
+ * @param config
119
+ */
120
+ static subscribeToGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
121
+ /**
122
+ * This endpoint unsubscribes from a group.
123
+ * @param id
124
+ * @param config
125
+ */
126
+ static unsubscribeFromGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
127
+ /**
128
+ * This endpoint allows to invite or accept a group invite.
129
+ * @param id
130
+ * @param data
131
+ * @param config
132
+ */
133
+ static inviteOrAcceptGroupRequest(id: number | string, data: {
134
+ users: number[];
135
+ }, config?: AxiosRequestConfig): Promise<any>;
136
+ /**
137
+ * This endpoint retrieves the group subscription status.
138
+ * @param id
139
+ * @param config
140
+ */
141
+ static getGroupSubscriptionStatus(id: number | string, config?: AxiosRequestConfig): Promise<any>;
142
+ /**
143
+ * This endpoint returns a list of the users waiting to be added to the group.
144
+ * @param id
145
+ * @param params
146
+ * @param config
147
+ */
148
+ static getGroupWaitingApprovalSubscribers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
149
+ }
150
+ /**
151
+ *
152
+ :::tip Incubator service can be used in the following way:
153
+
154
+ ```jsx
155
+ 1. Import the service from our library:
156
+
157
+ import {GroupService} from "@selfcommunity/api-services";
158
+ ```
159
+ ```jsx
160
+ 2. Create a function and put the service inside it!
161
+ The async function `searchGroups` will return the groups matching the search query.
162
+
163
+ async searchGroups() {
164
+ return await GroupService.searchGroups();
165
+ }
166
+ ```
167
+ ```jsx
168
+ In case of required `params`, just add them inside the brackets.
169
+
170
+ async getSpecificGroupInfo(groupId) {
171
+ return await GroupService.getSpecificGroupInfo(groupId);
172
+ }
173
+ ```
174
+ ```jsx
175
+ If you need to customize the request, you can add optional config params (`AxiosRequestConfig` type).
176
+
177
+ 1. Declare it(or declare them, it is possible to add multiple params)
178
+
179
+ const headers = headers: {Authorization: `Bearer ${yourToken}`}
180
+
181
+ 2. Add it inside the brackets and pass it to the function, as shown in the previous example!
182
+ ```
183
+ :::
184
+ */
185
+ export default class GroupService {
186
+ static getUserGroups(params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCGroupType>>;
187
+ static getAllGroups(params?: BaseSearchParams, 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 getGroupInvitedUsers(id: number | string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
199
+ static subscribeToGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
200
+ static unsubscribeFromGroup(id: number | string, config?: AxiosRequestConfig): Promise<any>;
201
+ static inviteOrAcceptGroupRequest(id: number | string, data: {
202
+ users: number[];
203
+ }, config?: AxiosRequestConfig): Promise<any>;
204
+ static getGroupSubscriptionStatus(id: number | string, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<any>>;
205
+ static getGroupWaitingApprovalSubscribers(id: number | string, params?: BaseGetParams, config?: AxiosRequestConfig): Promise<SCPaginatedResponse<SCUserType>>;
206
+ }
@@ -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 getAllGroups(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.GetAllGroups.url({})}?${p.toString()}`, method: Endpoints_1.default.GetAllGroups.method }));
29
+ }
30
+ /**
31
+ * This endpoint performs groups search
32
+ * @param params
33
+ * @param config
34
+ */
35
+ static searchGroups(params, config) {
36
+ const p = (0, url_1.urlParams)(params);
37
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: `${Endpoints_1.default.SearchGroups.url({})}?${p.toString()}`, method: Endpoints_1.default.SearchGroups.method }));
38
+ }
39
+ /**
40
+ * This endpoint retrieves a specific group.
41
+ * @param id
42
+ * @param config
43
+ */
44
+ static getSpecificGroupInfo(id, config) {
45
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.GetGroupInfo.url({ id }), method: Endpoints_1.default.GetGroupInfo.method }));
46
+ }
47
+ /**
48
+ * This endpoint performs groups search
49
+ * @param id
50
+ * @param params
51
+ * @param config
52
+ */
53
+ static getGroupFeed(id, params, config) {
54
+ const p = (0, url_1.urlParams)(params);
55
+ 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 }));
56
+ }
57
+ /**
58
+ * This endpoint creates a group.
59
+ * @param data
60
+ * @param config
61
+ */
62
+ static createGroup(data, config) {
63
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.CreateGroup.url({}), method: Endpoints_1.default.CreateGroup.method, data: data }));
64
+ }
65
+ /**
66
+ * This endpoint updates a group.
67
+ * @param id
68
+ * @param data
69
+ * @param config
70
+ */
71
+ static updateGroup(id, data, config) {
72
+ 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 }));
73
+ }
74
+ /**
75
+ * This endpoint patches a group.
76
+ * @param id
77
+ * @param data
78
+ * @param config
79
+ */
80
+ static patchGroup(id, data, config) {
81
+ 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 }));
82
+ }
83
+ /**
84
+ * This endpoint changes the group avatar
85
+ * @param id
86
+ * @param data
87
+ * @param config
88
+ */
89
+ static changeGroupAvatarOrCover(id, data, config) {
90
+ return (0, apiRequest_1.apiRequest)(Object.assign({ url: Endpoints_1.default.PatchGroup.url({ id }), method: Endpoints_1.default.PatchGroup.method, data }, config));
91
+ }
92
+ /**
93
+ * This endpoint returns all subscribers of a specific group.
94
+ * @param id
95
+ * @param params
96
+ * @param config
97
+ */
98
+ static getGroupMembers(id, params, config) {
99
+ const p = (0, url_1.urlParams)(params);
100
+ 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 }));
101
+ }
102
+ /**
103
+ * This endpoint returns a list of suggested users to invite to the group.
104
+ * @param id
105
+ * @param search
106
+ * @param config
107
+ */
108
+ static getGroupSuggestedUsers(id, search, config) {
109
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.GetGroupSuggestedUsers.url({ id, search }), method: Endpoints_1.default.GetGroupSuggestedUsers.method }));
110
+ }
111
+ /**
112
+ * This endpoint returns a list of suggested users to invite to the groups.
113
+ * @param search
114
+ * @param config
115
+ */
116
+ static getGroupsSuggestedUsers(search, config) {
117
+ return (0, apiRequest_1.apiRequest)(Object.assign(Object.assign({}, config), { url: Endpoints_1.default.GetGroupsSuggestedUsers.url({ search }), method: Endpoints_1.default.GetGroupsSuggestedUsers.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 getAllGroups(params, config) {
214
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
215
+ return GroupApiClient.getAllGroups(params, config);
216
+ });
217
+ }
218
+ static searchGroups(params, config) {
219
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
220
+ return GroupApiClient.searchGroups(params, config);
221
+ });
222
+ }
223
+ static getSpecificGroupInfo(id, config) {
224
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
225
+ return GroupApiClient.getSpecificGroupInfo(id, config);
226
+ });
227
+ }
228
+ static getGroupFeed(id, params, config) {
229
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
230
+ return GroupApiClient.getGroupFeed(id, params, config);
231
+ });
232
+ }
233
+ static createGroup(data, config) {
234
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
235
+ return GroupApiClient.createGroup(data, config);
236
+ });
237
+ }
238
+ static updateGroup(id, data, config) {
239
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
240
+ return GroupApiClient.updateGroup(id, data, config);
241
+ });
242
+ }
243
+ static patchGroup(id, data, config) {
244
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
245
+ return GroupApiClient.patchGroup(id, data, config);
246
+ });
247
+ }
248
+ static changeGroupAvatarOrCover(id, data, config) {
249
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
250
+ return GroupApiClient.changeGroupAvatarOrCover(id, data, config);
251
+ });
252
+ }
253
+ static getGroupMembers(id, params, config) {
254
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
255
+ return GroupApiClient.getGroupMembers(id, params, config);
256
+ });
257
+ }
258
+ static getGroupSuggestedUsers(id, search, config) {
259
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
260
+ return GroupApiClient.getGroupSuggestedUsers(id, search, config);
261
+ });
262
+ }
263
+ static getGroupsSuggestedUsers(search, config) {
264
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
265
+ return GroupApiClient.getGroupsSuggestedUsers(search, 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 });