diff --git a/.codegen.json b/.codegen.json index e3e5c496..89a9f0a0 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "41feeaa", "specHash": "6782a0d", "version": "1.13.2" } +{ "engineHash": "41feeaa", "specHash": "3dc6f70", "version": "1.13.2" } diff --git a/docs/README.md b/docs/README.md index 928d046e..e3286b9c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -49,6 +49,7 @@ the SDK are available by topic: - [Retention policy assignments](retentionPolicyAssignments.md) - [Search](search.md) - [Session termination](sessionTermination.md) +- [Shared links app items](sharedLinksAppItems.md) - [Shared links files](sharedLinksFiles.md) - [Shared links folders](sharedLinksFolders.md) - [Shared links web links](sharedLinksWebLinks.md) diff --git a/docs/sharedLinksAppItems.md b/docs/sharedLinksAppItems.md new file mode 100644 index 00000000..937f4c5c --- /dev/null +++ b/docs/sharedLinksAppItems.md @@ -0,0 +1,30 @@ +# SharedLinksAppItemsManager + +- [Find app item for shared link](#find-app-item-for-shared-link) + +## Find app item for shared link + +Returns the app item represented by a shared link. + +The link can originate from the current enterprise or another. + +This operation is performed by calling function `getSharedItemAppItems`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/get-shared-items--app-items/). + +_Currently we don't have an example for calling `getSharedItemAppItems` in integration tests_ + +### Arguments + +- headersInput `GetSharedItemAppItemsHeadersInput` + - Headers of getSharedItemAppItems method +- optionalsInput `GetSharedItemAppItemsOptionalsInput` + - + +### Returns + +This function returns a value of type `AppItem`. + +Returns a full app item resource if the shared link is valid and +the user has access to it. diff --git a/docs/sharedLinksWebLinks.md b/docs/sharedLinksWebLinks.md index 25bf1764..a7d2c063 100644 --- a/docs/sharedLinksWebLinks.md +++ b/docs/sharedLinksWebLinks.md @@ -49,7 +49,7 @@ await userClient.sharedLinksWebLinks.findWebLinkForSharedLink( This function returns a value of type `WebLink`. -Returns a full file resource if the shared link is valid and +Returns a full web link resource if the shared link is valid and the user has access to it. ## Get shared link for web link diff --git a/src/client.generated.ts b/src/client.generated.ts index bbff777f..04ea52c2 100644 --- a/src/client.generated.ts +++ b/src/client.generated.ts @@ -36,6 +36,7 @@ import { SharedLinksFoldersManager } from './managers/sharedLinksFolders.generat import { WebLinksManager } from './managers/webLinks.generated.js'; import { TrashedWebLinksManager } from './managers/trashedWebLinks.generated.js'; import { SharedLinksWebLinksManager } from './managers/sharedLinksWebLinks.generated.js'; +import { SharedLinksAppItemsManager } from './managers/sharedLinksAppItems.generated.js'; import { UsersManager } from './managers/users.generated.js'; import { SessionTerminationManager } from './managers/sessionTermination.generated.js'; import { AvatarsManager } from './managers/avatars.generated.js'; @@ -130,6 +131,7 @@ export class BoxClient { readonly webLinks: WebLinksManager; readonly trashedWebLinks: TrashedWebLinksManager; readonly sharedLinksWebLinks: SharedLinksWebLinksManager; + readonly sharedLinksAppItems: SharedLinksAppItemsManager; readonly users: UsersManager; readonly sessionTermination: SessionTerminationManager; readonly avatars: AvatarsManager; @@ -206,6 +208,7 @@ export class BoxClient { | 'webLinks' | 'trashedWebLinks' | 'sharedLinksWebLinks' + | 'sharedLinksAppItems' | 'users' | 'sessionTermination' | 'avatars' @@ -399,6 +402,10 @@ export class BoxClient { auth: this.auth, networkSession: this.networkSession, }); + this.sharedLinksAppItems = new SharedLinksAppItemsManager({ + auth: this.auth, + networkSession: this.networkSession, + }); this.users = new UsersManager({ auth: this.auth, networkSession: this.networkSession, diff --git a/src/managers/sharedLinksAppItems.generated.ts b/src/managers/sharedLinksAppItems.generated.ts new file mode 100644 index 00000000..5fcfa670 --- /dev/null +++ b/src/managers/sharedLinksAppItems.generated.ts @@ -0,0 +1,147 @@ +import { serializeAppItem } from '../schemas/appItem.generated.js'; +import { deserializeAppItem } from '../schemas/appItem.generated.js'; +import { serializeClientError } from '../schemas/clientError.generated.js'; +import { deserializeClientError } from '../schemas/clientError.generated.js'; +import { ResponseFormat } from '../networking/fetchOptions.generated.js'; +import { AppItem } from '../schemas/appItem.generated.js'; +import { ClientError } from '../schemas/clientError.generated.js'; +import { BoxSdkError } from '../box/errors.js'; +import { Authentication } from '../networking/auth.generated.js'; +import { NetworkSession } from '../networking/network.generated.js'; +import { FetchOptions } from '../networking/fetchOptions.generated.js'; +import { FetchResponse } from '../networking/fetchResponse.generated.js'; +import { prepareParams } from '../internal/utils.js'; +import { toString } from '../internal/utils.js'; +import { ByteStream } from '../internal/utils.js'; +import { CancellationToken } from '../internal/utils.js'; +import { sdToJson } from '../serialization/json.js'; +import { SerializedData } from '../serialization/json.js'; +import { sdIsEmpty } from '../serialization/json.js'; +import { sdIsBoolean } from '../serialization/json.js'; +import { sdIsNumber } from '../serialization/json.js'; +import { sdIsString } from '../serialization/json.js'; +import { sdIsList } from '../serialization/json.js'; +import { sdIsMap } from '../serialization/json.js'; +export class GetSharedItemAppItemsOptionals { + readonly cancellationToken?: CancellationToken = void 0; + constructor( + fields: Omit & + Partial>, + ) { + if (fields.cancellationToken !== undefined) { + this.cancellationToken = fields.cancellationToken; + } + } +} +export interface GetSharedItemAppItemsOptionalsInput { + readonly cancellationToken?: undefined | CancellationToken; +} +export class GetSharedItemAppItemsHeaders { + /** + * A header containing the shared link and optional password for the + * shared link. + * + * The format for this header is `shared_link=[link]&shared_link_password=[password]` */ + readonly boxapi!: string; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + } = {}; + constructor( + fields: Omit & + Partial>, + ) { + if (fields.boxapi !== undefined) { + this.boxapi = fields.boxapi; + } + if (fields.extraHeaders !== undefined) { + this.extraHeaders = fields.extraHeaders; + } + } +} +export interface GetSharedItemAppItemsHeadersInput { + /** + * A header containing the shared link and optional password for the + * shared link. + * + * The format for this header is `shared_link=[link]&shared_link_password=[password]` */ + readonly boxapi: string; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: + | undefined + | { + readonly [key: string]: undefined | string; + }; +} +export class SharedLinksAppItemsManager { + readonly auth?: Authentication; + readonly networkSession: NetworkSession = new NetworkSession({}); + constructor( + fields: Omit< + SharedLinksAppItemsManager, + 'networkSession' | 'getSharedItemAppItems' + > & + Partial>, + ) { + if (fields.auth !== undefined) { + this.auth = fields.auth; + } + if (fields.networkSession !== undefined) { + this.networkSession = fields.networkSession; + } + } + /** + * Returns the app item represented by a shared link. + * + * The link can originate from the current enterprise or another. + * @param {GetSharedItemAppItemsHeadersInput} headersInput Headers of getSharedItemAppItems method + * @param {GetSharedItemAppItemsOptionalsInput} optionalsInput + * @returns {Promise} + */ + async getSharedItemAppItems( + headersInput: GetSharedItemAppItemsHeadersInput, + optionalsInput: GetSharedItemAppItemsOptionalsInput = {}, + ): Promise { + const headers: GetSharedItemAppItemsHeaders = + new GetSharedItemAppItemsHeaders({ + boxapi: headersInput.boxapi, + extraHeaders: headersInput.extraHeaders, + }); + const optionals: GetSharedItemAppItemsOptionals = + new GetSharedItemAppItemsOptionals({ + cancellationToken: optionalsInput.cancellationToken, + }); + const cancellationToken: any = optionals.cancellationToken; + const headersMap: { + readonly [key: string]: string; + } = prepareParams({ + ...{ ['boxapi']: toString(headers.boxapi) as string }, + ...headers.extraHeaders, + }); + const response: FetchResponse = + await this.networkSession.networkClient.fetch( + new FetchOptions({ + url: ''.concat( + this.networkSession.baseUrls.baseUrl, + '/2.0/shared_items#app_items', + ) as string, + method: 'GET', + headers: headersMap, + responseFormat: 'json' as ResponseFormat, + auth: this.auth, + networkSession: this.networkSession, + cancellationToken: cancellationToken, + }), + ); + return { + ...deserializeAppItem(response.data!), + rawData: response.data!, + }; + } +} +export interface SharedLinksAppItemsManagerInput { + readonly auth?: Authentication; + readonly networkSession?: NetworkSession; +}