Skip to content

Commit

Permalink
fix(hub-discussions): remove files/fns that were duplicated between h…
Browse files Browse the repository at this point in the history
…ub-discussions and hub-common p

affects: @esri/hub-discussions

ISSUES CLOSED: 11042
  • Loading branch information
rweber-esri committed Nov 19, 2024
1 parent 12b1ce9 commit e49319d
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 375 deletions.
21 changes: 12 additions & 9 deletions packages/discussions/src/channels/channels.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { request } from "../request";
import { discussionsApiRequest } from "@esri/hub-common";
import {
ICreateChannelParams,
IFetchChannelParams,
Expand Down Expand Up @@ -28,7 +28,7 @@ export function createChannel(
options: ICreateChannelParams
): Promise<IChannel> {
options.httpMethod = "POST";
return request(`/channels`, options);
return discussionsApiRequest(`/channels`, options);
}

/**
Expand All @@ -40,7 +40,7 @@ export function createChannel(
*/
export function fetchChannel(options: IFetchChannelParams): Promise<IChannel> {
options.httpMethod = "GET";
return request(`/channels/${options.channelId}`, options);
return discussionsApiRequest(`/channels/${options.channelId}`, options);
}

/**
Expand All @@ -56,7 +56,7 @@ export function updateChannel(
options: IUpdateChannelParams
): Promise<IChannel> {
options.httpMethod = "PATCH";
return request(`/channels/${options.channelId}`, options);
return discussionsApiRequest(`/channels/${options.channelId}`, options);
}

/**
Expand All @@ -70,7 +70,7 @@ export function removeChannel(
options: IRemoveChannelParams
): Promise<IRemoveChannelResponse> {
options.httpMethod = "DELETE";
return request(`/channels/${options.channelId}`, options);
return discussionsApiRequest(`/channels/${options.channelId}`, options);
}

/**
Expand All @@ -84,7 +84,7 @@ export function fetchChannelNotifcationOptOut(
options: IFetchChannelNotificationOptOutParams
): Promise<IChannelNotificationOptOut> {
options.httpMethod = "GET";
return request(
return discussionsApiRequest(
`/channels/${options.channelId}/notifications/opt-out`,
options
);
Expand All @@ -101,7 +101,7 @@ export function createChannelNotificationOptOut(
options: ICreateChannelNotificationOptOutParams
): Promise<IChannelNotificationOptOut> {
options.httpMethod = "POST";
return request(
return discussionsApiRequest(
`/channels/${options.channelId}/notifications/opt-out`,
options
);
Expand All @@ -118,7 +118,7 @@ export function removeChannelNotificationOptOut(
options: IRemoveChannelNotificationOptOutParams
): Promise<IRemoveChannelNotificationOptOutResult> {
options.httpMethod = "DELETE";
return request(
return discussionsApiRequest(
`/channels/${options.channelId}/notifications/opt-out`,
options
);
Expand All @@ -135,5 +135,8 @@ export function removeChannelActivity(
options: IRemoveChannelActivityParams
): Promise<IRemoveChannelActivityResult> {
options.httpMethod = "DELETE";
return request(`/channels/${options.channelId}/activity`, options);
return discussionsApiRequest(
`/channels/${options.channelId}/activity`,
options
);
}
16 changes: 8 additions & 8 deletions packages/discussions/src/posts/posts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* tslint:disable unified-signatures */
import { request } from "../request";
import { discussionsApiRequest } from "@esri/hub-common";
import {
ICreatePostParams,
ICreateReplyParams,
Expand Down Expand Up @@ -35,7 +35,7 @@ export function searchPosts(
: acc,
{ ...(options.data ?? {}) } as any
);
return request(url, {
return discussionsApiRequest(url, {
...options,
data,
httpMethod: "GET",
Expand All @@ -51,7 +51,7 @@ export function searchPosts(
*/
export function createPost(options: ICreatePostParams): Promise<IPost> {
const url = `/posts`;
return request(url, {
return discussionsApiRequest(url, {
httpMethod: "POST",
...getCreateUpdateRequestParams(options),
});
Expand All @@ -67,7 +67,7 @@ export function createPost(options: ICreatePostParams): Promise<IPost> {
*/
export function createReply(options: ICreateReplyParams): Promise<IPost> {
const url = `/posts/${options.postId}/reply`;
return request(url, {
return discussionsApiRequest(url, {
httpMethod: "POST",
...getCreateUpdateRequestParams(options),
});
Expand All @@ -83,7 +83,7 @@ export function createReply(options: ICreateReplyParams): Promise<IPost> {
export function fetchPost(params: IFetchPostParams): Promise<IPost> {
const url = `/posts/${params.postId}`;
params.httpMethod = "GET";
return request(url, params);
return discussionsApiRequest(url, params);
}

/**
Expand All @@ -98,7 +98,7 @@ export function removePost(
): Promise<IRemovePostResponse> {
const url = `/posts/${options.postId}`;
options.httpMethod = "DELETE";
return request(url, options);
return discussionsApiRequest(url, options);
}

/**
Expand All @@ -111,7 +111,7 @@ export function removePost(
*/
export function updatePost(options: IUpdatePostParams): Promise<IPost> {
const url = `/posts/${options.postId}`;
return request(url, {
return discussionsApiRequest(url, {
httpMethod: "PATCH",
...getCreateUpdateRequestParams(options),
});
Expand All @@ -130,7 +130,7 @@ export function updatePostStatus(
): Promise<IPost> {
const url = `/posts/${options.postId}/status`;
options.httpMethod = "PATCH";
return request(url, options);
return discussionsApiRequest(url, options);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/discussions/src/reactions/reactions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { request } from "../request";
import { discussionsApiRequest } from "@esri/hub-common";
import {
ICreateReactionOptions,
IRemoveReactionOptions,
Expand All @@ -17,7 +17,7 @@ export function createReaction(
options: ICreateReactionOptions
): Promise<IReaction> {
options.httpMethod = "POST";
return request(`/reactions`, options);
return discussionsApiRequest(`/reactions`, options);
}

/**
Expand All @@ -32,5 +32,5 @@ export function removeReaction(
): Promise<IRemoveReactionResponse> {
const { reactionId } = options;
options.httpMethod = "DELETE";
return request(`/reactions/${reactionId}`, options);
return discussionsApiRequest(`/reactions/${reactionId}`, options);
}
24 changes: 0 additions & 24 deletions packages/discussions/src/request.ts

This file was deleted.

103 changes: 0 additions & 103 deletions packages/discussions/src/utils/request.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/discussions/test/channels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
removeChannelNotificationOptOut,
removeChannelActivity,
} from "../src/channels";
import * as req from "../src/request";
import * as hubCommon from "@esri/hub-common";
import {
AclCategory,
AclSubCategory,
Expand All @@ -30,7 +30,7 @@ describe("channels", () => {
} as unknown as IDiscussionsRequestOptions;

beforeEach(() => {
requestSpy = spyOn(req, "request").and.returnValue(
requestSpy = spyOn(hubCommon, "discussionsApiRequest").and.returnValue(
Promise.resolve(response)
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/discussions/test/posts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
createReply,
updatePostStatus,
} from "../src/posts";
import * as req from "../src/request";
import * as hubCommon from "@esri/hub-common";
import {
AclCategory,
AclSubCategory,
Expand All @@ -28,7 +28,7 @@ describe("posts", () => {
} as unknown as IDiscussionsRequestOptions;

beforeEach(() => {
requestSpy = spyOn(req, "request").and.returnValue(
requestSpy = spyOn(hubCommon, "discussionsApiRequest").and.returnValue(
Promise.resolve(response)
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/discussions/test/reactions.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createReaction, removeReaction } from "../src/reactions";
import * as req from "../src/request";
import * as hubCommon from "@esri/hub-common";
import { IDiscussionsRequestOptions, PostReaction } from "../src/types";

describe("reactions", () => {
Expand All @@ -11,7 +11,7 @@ describe("reactions", () => {
};

beforeEach(() => {
requestSpy = spyOn(req, "request").and.returnValue(
requestSpy = spyOn(hubCommon, "discussionsApiRequest").and.returnValue(
Promise.resolve(response)
);
});
Expand Down
Loading

0 comments on commit e49319d

Please sign in to comment.