Skip to content

Commit 28b7d92

Browse files
feat: [FEEDS-849] Feeds collections (#204)
1 parent 94e45da commit 28b7d92

File tree

3 files changed

+269
-0
lines changed

3 files changed

+269
-0
lines changed

src/gen/feeds/FeedsApi.ts

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {
1919
AddReactionRequest,
2020
AddReactionResponse,
2121
CastPollVoteRequest,
22+
CreateCollectionsRequest,
23+
CreateCollectionsResponse,
2224
CreateFeedGroupRequest,
2325
CreateFeedGroupResponse,
2426
CreateFeedViewRequest,
@@ -33,6 +35,7 @@ import {
3335
DeleteActivityResponse,
3436
DeleteBookmarkFolderResponse,
3537
DeleteBookmarkResponse,
38+
DeleteCollectionsResponse,
3639
DeleteCommentReactionResponse,
3740
DeleteCommentResponse,
3841
DeleteFeedGroupResponse,
@@ -89,6 +92,7 @@ import {
8992
QueryFollowsResponse,
9093
QueryMembershipLevelsRequest,
9194
QueryMembershipLevelsResponse,
95+
ReadCollectionsResponse,
9296
RejectFeedMemberInviteRequest,
9397
RejectFeedMemberInviteResponse,
9498
RejectFollowRequest,
@@ -107,6 +111,8 @@ import {
107111
UpdateBookmarkFolderResponse,
108112
UpdateBookmarkRequest,
109113
UpdateBookmarkResponse,
114+
UpdateCollectionsRequest,
115+
UpdateCollectionsResponse,
110116
UpdateCommentRequest,
111117
UpdateCommentResponse,
112118
UpdateFeedGroupRequest,
@@ -125,6 +131,8 @@ import {
125131
UpdateMembershipLevelResponse,
126132
UpsertActivitiesRequest,
127133
UpsertActivitiesResponse,
134+
UpsertCollectionsRequest,
135+
UpsertCollectionsResponse,
128136
} from '../models';
129137
import { decoders } from '../model-decoders/decoders';
130138

@@ -147,6 +155,7 @@ export class FeedsApi {
147155
visibility: request?.visibility,
148156
visibility_tag: request?.visibility_tag,
149157
attachments: request?.attachments,
158+
collection_refs: request?.collection_refs,
150159
filter_tags: request?.filter_tags,
151160
interest_tags: request?.interest_tags,
152161
mentioned_user_ids: request?.mentioned_user_ids,
@@ -594,6 +603,7 @@ export class FeedsApi {
594603
user_id: request?.user_id,
595604
visibility: request?.visibility,
596605
attachments: request?.attachments,
606+
collection_refs: request?.collection_refs,
597607
feeds: request?.feeds,
598608
filter_tags: request?.filter_tags,
599609
interest_tags: request?.interest_tags,
@@ -722,6 +732,113 @@ export class FeedsApi {
722732
return { ...response.body, metadata: response.metadata };
723733
}
724734

735+
async deleteCollections(request: {
736+
collection_refs: string[];
737+
}): Promise<StreamResponse<DeleteCollectionsResponse>> {
738+
const queryParams = {
739+
collection_refs: request?.collection_refs,
740+
};
741+
742+
const response = await this.apiClient.sendRequest<
743+
StreamResponse<DeleteCollectionsResponse>
744+
>('DELETE', '/api/v2/feeds/collections', undefined, queryParams);
745+
746+
decoders.DeleteCollectionsResponse?.(response.body);
747+
748+
return { ...response.body, metadata: response.metadata };
749+
}
750+
751+
async readCollections(request: {
752+
collection_refs: string[];
753+
user_id?: string;
754+
}): Promise<StreamResponse<ReadCollectionsResponse>> {
755+
const queryParams = {
756+
collection_refs: request?.collection_refs,
757+
user_id: request?.user_id,
758+
};
759+
760+
const response = await this.apiClient.sendRequest<
761+
StreamResponse<ReadCollectionsResponse>
762+
>('GET', '/api/v2/feeds/collections', undefined, queryParams);
763+
764+
decoders.ReadCollectionsResponse?.(response.body);
765+
766+
return { ...response.body, metadata: response.metadata };
767+
}
768+
769+
async updateCollections(
770+
request: UpdateCollectionsRequest,
771+
): Promise<StreamResponse<UpdateCollectionsResponse>> {
772+
const body = {
773+
collections: request?.collections,
774+
user_id: request?.user_id,
775+
user: request?.user,
776+
};
777+
778+
const response = await this.apiClient.sendRequest<
779+
StreamResponse<UpdateCollectionsResponse>
780+
>(
781+
'PATCH',
782+
'/api/v2/feeds/collections',
783+
undefined,
784+
undefined,
785+
body,
786+
'application/json',
787+
);
788+
789+
decoders.UpdateCollectionsResponse?.(response.body);
790+
791+
return { ...response.body, metadata: response.metadata };
792+
}
793+
794+
async createCollections(
795+
request: CreateCollectionsRequest,
796+
): Promise<StreamResponse<CreateCollectionsResponse>> {
797+
const body = {
798+
collections: request?.collections,
799+
user_id: request?.user_id,
800+
user: request?.user,
801+
};
802+
803+
const response = await this.apiClient.sendRequest<
804+
StreamResponse<CreateCollectionsResponse>
805+
>(
806+
'POST',
807+
'/api/v2/feeds/collections',
808+
undefined,
809+
undefined,
810+
body,
811+
'application/json',
812+
);
813+
814+
decoders.CreateCollectionsResponse?.(response.body);
815+
816+
return { ...response.body, metadata: response.metadata };
817+
}
818+
819+
async upsertCollections(
820+
request: UpsertCollectionsRequest,
821+
): Promise<StreamResponse<UpsertCollectionsResponse>> {
822+
const body = {
823+
collections: request?.collections,
824+
};
825+
826+
const response = await this.apiClient.sendRequest<
827+
StreamResponse<UpsertCollectionsResponse>
828+
>(
829+
'PUT',
830+
'/api/v2/feeds/collections',
831+
undefined,
832+
undefined,
833+
body,
834+
'application/json',
835+
);
836+
837+
decoders.UpsertCollectionsResponse?.(response.body);
838+
839+
return { ...response.body, metadata: response.metadata };
840+
}
841+
725842
async getComments(request: {
726843
object_id: string;
727844
object_type: string;

src/gen/model-decoders/decoders.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ decoders.ActivityResponse = (input?: Record<string, any>) => {
216216

217217
own_reactions: { type: 'FeedsReactionResponse', isSingle: false },
218218

219+
collections: { type: 'EnrichedCollectionResponse', isSingle: false },
220+
219221
reaction_groups: { type: 'ReactionGroupResponse', isSingle: false },
220222

221223
user: { type: 'UserResponse', isSingle: true },
@@ -1512,6 +1514,15 @@ decoders.ClosedCaptionEvent = (input?: Record<string, any>) => {
15121514
return decode(typeMappings, input);
15131515
};
15141516

1517+
decoders.CollectionResponse = (input?: Record<string, any>) => {
1518+
const typeMappings: TypeMapping = {
1519+
created_at: { type: 'DatetimeType', isSingle: true },
1520+
1521+
updated_at: { type: 'DatetimeType', isSingle: true },
1522+
};
1523+
return decode(typeMappings, input);
1524+
};
1525+
15151526
decoders.Command = (input?: Record<string, any>) => {
15161527
const typeMappings: TypeMapping = {
15171528
created_at: { type: 'DatetimeType', isSingle: true },
@@ -1671,6 +1682,13 @@ decoders.CreateChannelTypeResponse = (input?: Record<string, any>) => {
16711682
return decode(typeMappings, input);
16721683
};
16731684

1685+
decoders.CreateCollectionsResponse = (input?: Record<string, any>) => {
1686+
const typeMappings: TypeMapping = {
1687+
collections: { type: 'CollectionResponse', isSingle: false },
1688+
};
1689+
return decode(typeMappings, input);
1690+
};
1691+
16741692
decoders.CreateCommandResponse = (input?: Record<string, any>) => {
16751693
const typeMappings: TypeMapping = {
16761694
command: { type: 'Command', isSingle: true },
@@ -1857,6 +1875,15 @@ decoders.EgressRTMPResponse = (input?: Record<string, any>) => {
18571875
return decode(typeMappings, input);
18581876
};
18591877

1878+
decoders.EnrichedCollectionResponse = (input?: Record<string, any>) => {
1879+
const typeMappings: TypeMapping = {
1880+
created_at: { type: 'DatetimeType', isSingle: true },
1881+
1882+
updated_at: { type: 'DatetimeType', isSingle: true },
1883+
};
1884+
return decode(typeMappings, input);
1885+
};
1886+
18601887
decoders.EntityCreatorResponse = (input?: Record<string, any>) => {
18611888
const typeMappings: TypeMapping = {
18621889
created_at: { type: 'DatetimeType', isSingle: true },
@@ -3672,6 +3699,13 @@ decoders.ReactivateUserResponse = (input?: Record<string, any>) => {
36723699
return decode(typeMappings, input);
36733700
};
36743701

3702+
decoders.ReadCollectionsResponse = (input?: Record<string, any>) => {
3703+
const typeMappings: TypeMapping = {
3704+
collections: { type: 'CollectionResponse', isSingle: false },
3705+
};
3706+
return decode(typeMappings, input);
3707+
};
3708+
36753709
decoders.ReadStateResponse = (input?: Record<string, any>) => {
36763710
const typeMappings: TypeMapping = {
36773711
last_read: { type: 'DatetimeType', isSingle: true },
@@ -4278,6 +4312,13 @@ decoders.UpdateChannelTypeResponse = (input?: Record<string, any>) => {
42784312
return decode(typeMappings, input);
42794313
};
42804314

4315+
decoders.UpdateCollectionsResponse = (input?: Record<string, any>) => {
4316+
const typeMappings: TypeMapping = {
4317+
collections: { type: 'CollectionResponse', isSingle: false },
4318+
};
4319+
return decode(typeMappings, input);
4320+
};
4321+
42814322
decoders.UpdateCommandResponse = (input?: Record<string, any>) => {
42824323
const typeMappings: TypeMapping = {
42834324
command: { type: 'Command', isSingle: true },
@@ -4394,6 +4435,13 @@ decoders.UpsertActivitiesResponse = (input?: Record<string, any>) => {
43944435
return decode(typeMappings, input);
43954436
};
43964437

4438+
decoders.UpsertCollectionsResponse = (input?: Record<string, any>) => {
4439+
const typeMappings: TypeMapping = {
4440+
collections: { type: 'CollectionResponse', isSingle: false },
4441+
};
4442+
return decode(typeMappings, input);
4443+
};
4444+
43974445
decoders.UpsertConfigResponse = (input?: Record<string, any>) => {
43984446
const typeMappings: TypeMapping = {
43994447
config: { type: 'ConfigResponse', isSingle: true },

0 commit comments

Comments
 (0)