import {wix} from './proto-generated'; import {HttpClient, ClientOptions} from '@wix/catalyst-platformized-http-client'; // TODO this boilerplate can be generated from protobuf export class AppSettingsServiceClient { private httpClient: HttpClient; constructor(options: ClientOptions) { this.httpClient = HttpClient.fromClientOptions(options); } updateAppSettings(req: wix.filesharing.api.v1.settings.UpdateAppSettingsRequest): Promise { return this.httpClient.patch('/api/v1/file-sharing/settings', this.settings('UpdateAppSettingsRequest'), this.settings('UpdateAppSettingsResponse'), req); } getAppSettings(req: wix.filesharing.api.v1.settings.GetAppSettingsRequest): Promise { return this.httpClient.get('/api/v1/file-sharing/settings', this.settings('GetAppSettingsRequest'), this.settings('GetAppSettingsResponse'), req); } private settings(clazz: string): string { return `wix.filesharing.api.v1.settings.${clazz}`; } } export class FileSharingServiceClient { private httpClient: HttpClient; constructor(options: ClientOptions) { this.httpClient = HttpClient.fromClientOptions(options); } queryLibraryItems(req: wix.filesharing.api.v1.libraryitems.QueryLibraryItemsRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/library-items/query', this.libraryItems('QueryLibraryItemsRequest'), this.libraryItems('QueryLibraryItemsResponse'), req); } queryLibraryFolderItems(req: wix.filesharing.api.v1.libraryitems.QueryLibraryFolderItemsRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/library-folder-items/query', this.libraryItems('QueryLibraryFolderItemsRequest'), this.libraryItems('QueryLibraryFolderItemsResponse'), req); } getLibraryItemsById(req: wix.filesharing.api.v1.libraryitems.GetLibraryItemsByIdRequest): Promise { return this.httpClient.get('/api/v1/file-sharing/library-items', this.libraryItems('GetLibraryItemsByIdRequest'), this.libraryItems('GetLibraryItemsByIdResponse'), req); } listAllowedActions(req: wix.filesharing.api.v1.libraryitems.ListAllowedActionsRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/list-allowed-actions', this.libraryItems('ListAllowedActionsRequest'), this.libraryItems('ListAllowedActionsResponse'), req); } getFolderTree(req: wix.filesharing.api.v1.libraryitems.GetFolderTreeRequest): Promise { return this.httpClient.get('/api/v1/file-sharing/folder-trees', this.libraryItems('GetFolderTreeRequest'), this.libraryItems('GetFolderTreeResponse'), req); } createFolder(req: wix.filesharing.api.v1.libraryitems.CreateFolderRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/folders', this.libraryItems('CreateFolderRequest'), this.libraryItems('CreateFolderResponse'), req); } move(req: wix.filesharing.api.v1.libraryitems.MoveRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/library-items/move', this.libraryItems('MoveRequest'), this.libraryItems('MoveResponse'), req); } rename(req: wix.filesharing.api.v1.libraryitems.RenameRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/library-items/rename', this.libraryItems('RenameRequest'), this.libraryItems('RenameResponse'), req); } delete(req: wix.filesharing.api.v1.libraryitems.DeleteRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/library-items/delete', this.libraryItems('DeleteRequest'), this.libraryItems('DeleteResponse'), req); } viewFile(req: wix.filesharing.api.v1.libraryitems.ViewFileRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/library-items/view-file', this.libraryItems('ViewFileRequest'), this.libraryItems('ViewFileResponse'), req); } viewFolder(req: wix.filesharing.api.v1.libraryitems.ViewFolderRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/library-items/view-folder', this.libraryItems('ViewFolderRequest'), this.libraryItems('ViewFolderResponse'), req); } favorite(req: wix.filesharing.api.v1.libraryitems.FavoriteRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/library-items/favorite', this.libraryItems('FavoriteRequest'), this.libraryItems('FavoriteResponse'), req); } download(req: wix.filesharing.api.v1.libraryitems.DownloadRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/library-items/download', this.libraryItems('DownloadRequest'), this.libraryItems('DownloadResponse'), req); } startFileUpload(req: wix.filesharing.api.v1.libraryitems.StartFileUploadRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/files/start-upload', this.libraryItems('StartFileUploadRequest'), this.libraryItems('StartFileUploadResponse'), req); } completeFileUpload(req: wix.filesharing.api.v1.libraryitems.CompleteFileUploadRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/files/complete-upload', this.libraryItems('CompleteFileUploadRequest'), this.libraryItems('CompleteFileUploadResponse'), req); } share(req: wix.filesharing.api.v1.libraryitems.ShareRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/library-items/share', this.libraryItems('ShareRequest'), this.libraryItems('ShareResponse'), req); } private libraryItems(clazz: string): string { return `wix.filesharing.api.v1.libraryitems.${clazz}`; } } export class PermissionsServiceClient { private httpClient: HttpClient; constructor(options: ClientOptions) { this.httpClient = HttpClient.fromClientOptions(options); } remove(req: wix.filesharing.api.v1.permissions.RemoveRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/permissions/remove', this.permissions('RemoveRequest'), this.permissions('RemoveResponse'), req); } assign(req: wix.filesharing.api.v1.permissions.AssignRequest): Promise { return this.httpClient.post('/api/v1/file-sharing/permissions/assign', this.permissions('AssignRequest'), this.permissions('AssignResponse'), req); } listRoles(req: wix.filesharing.api.v1.permissions.ListRolesRequest): Promise { return this.httpClient.get('/api/v1/file-sharing/roles', this.permissions('ListRolesRequest'), this.permissions('ListRolesResponse'), req); } private permissions(clazz: string): string { return `wix.filesharing.api.v1.permissions.${clazz}`; } }