Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: teach hubSearch channels #1111

Merged
merged 15 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/common/src/discussions/api/channels/channels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { request } from "../request";
import { IChannel, IPagedResponse, ISearchChannelsParams } from "../types";

/**
* Search for Channels in the Discussions API. Channels define the capabilities,
* permissions, and configuration for Discussion posts.
*
tannerjt marked this conversation as resolved.
Show resolved Hide resolved
* @export
* @param {ISearchChannelsParams} options
* @return {*} {Promise<IPagedResponse<IChannel>>}
*/
export function searchChannels(
options: ISearchChannelsParams
): Promise<IPagedResponse<IChannel>> {
options.httpMethod = "GET";
return request(`/channels`, options);
}
1 change: 1 addition & 0 deletions packages/common/src/discussions/api/channels/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./channels";
2 changes: 2 additions & 0 deletions packages/common/src/discussions/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./channels";
export * from "./types";
24 changes: 24 additions & 0 deletions packages/common/src/discussions/api/request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { IDiscussionsRequestOptions } from "./types";
import { apiRequest, authenticateRequest } from "./utils/request";

/**
* method that authenticates and makes requests to Discussions API
*
* @export
* @template T
* @param {string} url
* @param {IDiscussionsRequestOptions} options
* @return {*} {Promise<T>}
*/
// NOTE: feasibly this could be replaced with @esi/hub-common hubApiRequest,
// if that method didn't prepend `/api/v3` to the supplied path. Additionally,
// there is the difference that hubApiRequest sets Authorization header without `Bearer`
// https://github.com/Esri/hub.js/blob/f35b1a0a868916bd07e1dfd84cb084bc2c876267/packages/common/src/request.ts#L62
export function request<T>(
url: string,
options: IDiscussionsRequestOptions
): Promise<T> {
return authenticateRequest(options).then((token) => {
return apiRequest(url, options, token);
});
}
Loading