import { HttpClient } from '@angular/common/http'; import { ToastrService } from 'ngx-toastr'; import { Observable, Subject } from 'rxjs'; import { Metadata, SpParams } from '../models/share-point'; export declare type SharePointApiRoute = '_vti_bin/listdata.svc/' | '_api/web/'; export interface Message { title?: string; message?: string; } interface SpHeaders { Accept: 'application/json;odata=verbose' | 'application/json;odata=minimalmetadata' | 'application/json;odata=nometadata'; } interface SpOnSuccess { onSuccess?: Message; hideOnSuccess?: boolean; } interface SpOnError { onError?: Message; hideOnErrors?: boolean; } interface SpOptions extends SpOnError { listRoute?: string; headers?: SpHeaders; useLegacyApi?: boolean; service?: boolean; } export interface SpGetOptions extends SpOptions { params?: SpParams; } export interface SpPostOptions extends SpOptions, SpOnSuccess { remove?: boolean; match?: string; } export interface SpPostAttachmentOptions extends SpOptions, SpOnSuccess { } export declare class SpRequest { listName: string; options: SpGetOptions; constructor(listName: string, options: SpGetOptions); } export interface SpBatchGetRequest { listName: string; options?: { params: SpParams; listRoute?: string; }; } export interface SpBatchPostOptions extends SpPostOptions { listName?: string; } export interface SpBatchPostRequest { value: any; listName?: string; options?: { listRoute?: string; remove?: boolean; match?: string; }; } export interface HasMetadata { __metadata?: Metadata; } export interface Attachment { FileName: string; ServerRelativeUrl: string; __metadata: { id: string; uri: string; type: 'SP.Attachment'; }; } export declare class SharePointService { private http; private toast; private _digestsByUrl; constructor(http: HttpClient, toast: ToastrService); private _onError; private _onSuccess; private _spGet; private _getRoute; private _createUri; digest({ __metadata }: HasMetadata, { listRoute, useLegacyApi }?: SpPostOptions): Observable; private _addDigestToCache; /** * Construct a SharePoint GET request using angular HttpClient and return only the results of the request as `T`. * @param listName as `string` name of SharePoint List * @param options as `SpGetOptions` options for params, and error messages * @return an `Observable` of the body as type `T[]`. */ get(listName: string, options?: SpGetOptions): Observable; /** * Construct a SharePoint Post request using angular HttpClient and return only the results of the request as `T`. * @param listName as `string` name of SharePoint List * @param body as `any` body to be updated or removed * @param options as `SpPostOptions` options for error messages, success messages, and if the item should be removed * @return an `Observable` of the body as type `T`. */ post(listName: string, body: any, options?: SpPostOptions): Observable; attach(list: string, file: File, item: any, options?: SpPostAttachmentOptions): Observable; attachMultiple(list: string, files: File[], item: any): Observable; fileReader(attachment: File): Subject; /** * Cleans up any meta data that may cause issues when posinting to SharePoint and adds required data to meta data * @param listName as `string` name of SharePoint List * @param body as `any` body to be updated or removed * @param options as `SpPostOptions` options for error messages, success messages, and if the item should be removed * @return an copy of the body. */ cleanBody(listName: string, body: any, { useLegacyApi }?: SpPostOptions): any; /** * Construct a SharePoint GET request using angular HttpClient and return only the results of the request as `T`. * @param requests as `SpBatchGetRequest[]` name of SharePoint List * @param options as `SpGetOptions` * @return an `Observable` of the body as type `any[]`. */ batchGet(requests: SpBatchGetRequest[], options?: SpGetOptions): Observable; /** * Construct a SharePoint GET request using angular HttpClient and return only the results of the request as `T`. * @param requests as `SpBatchPostRequest[]` name of SharePoint List * @param options as `SpGetOptions` * @return an `Observable` of the body as type `any[]`. */ batchPost(requests: SpBatchPostRequest[], options?: SpBatchPostOptions): Observable; private _chunkBatch; private _forkJoinBatches; private _batchBody; private _batchRequest; private _parseBatchResponse; private _setType; private _getItemType; private _generateUUID; } export declare class SharePointModule { } export {};