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