/*- * ============LICENSE_START======================================================= * SDC * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ // Type definitions for Restangular v1.4.0 // Project: https://github.com/mgonto/restangular // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped /// // Support AMD require (copying angular.d.ts approach) // allows for import {IRequestConfig} from 'restangular' ES6 approach declare module 'restangular' { export = restangular; } declare module restangular { interface IPromise extends angular.IPromise { call(methodName: string, params?: any): IPromise; get(fieldName: string): IPromise; $object: T; } interface ICollectionPromise extends angular.IPromise { push(object: any): ICollectionPromise; call(methodName: string, params?: any): ICollectionPromise; get(fieldName: string): ICollectionPromise; $object: T[]; } interface IResponse { status: number; data: any; headers(name: string): string; config: { method: string; url: string; params: any; } } interface IProvider { setBaseUrl(baseUrl: string): void; setExtraFields(fields: string[]): void; setParentless(parentless: boolean, routes: string[]): void; setDefaultHttpFields(httpFields: any): void; addElementTransformer(route: string, transformer: Function): void; addElementTransformer(route: string, isCollection: boolean, transformer: Function): void; setTransformOnlyServerElements(active: boolean): void; setOnElemRestangularized(callback: (elem: any, isCollection: boolean, what: string, restangular: IService) => any): void; setResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: IResponse, deferred: angular.IDeferred) => any): void; setResponseExtractor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: IResponse, deferred: angular.IDeferred) => any): void; addResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: IResponse, deferred: angular.IDeferred) => any): void; setRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void; addRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void; setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: angular.IRequestShortcutConfig) => {element: any; headers: any; params: any}): void; addFullRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: angular.IRequestShortcutConfig) => {headers: any; params: any; element: any; httpConfig: angular.IRequestShortcutConfig}): void; setErrorInterceptor(errorInterceptor: (response: IResponse, deferred: angular.IDeferred) => any): void; setRestangularFields(fields: {[fieldName: string]: string}): void; setMethodOverriders(overriders: string[]): void; setJsonp(jsonp: boolean): void; setDefaultRequestParams(params: any): void; setDefaultRequestParams(method: string, params: any): void; setDefaultRequestParams(methods: string[], params: any): void; setFullResponse(fullResponse: boolean): void; setDefaultHeaders(headers: any): void; setRequestSuffix(suffix: string): void; setUseCannonicalId(useCannonicalId: boolean): void; setEncodeIds(encode: boolean): void; } interface ICustom { customGET(path: string, params?: any, headers?: any): IPromise; customGETLIST(path: string, params?: any, headers?: any): ICollectionPromise; customDELETE(path: string, params?: any, headers?: any): IPromise; customPOST(elem?: any, path?: string, params?: any, headers?: any): IPromise; customPUT(elem?: any, path?: string, params?: any, headers?: any): IPromise; customOperation(operation: string, path: string, params?: any, headers?: any, elem?: any): IPromise; addRestangularMethod(name: string, operation: string, path?: string, params?: any, headers?: any, elem?: any): IPromise; } interface IService extends ICustom, IProvider { one(route: string, id?: number): IElement; one(route: string, id?: string): IElement; oneUrl(route: string, url: string): IElement; all(route: string): IElement; allUrl(route: string, url: string): IElement; copy(fromElement: any): IElement; withConfig(configurer: (RestangularProvider: IProvider) => any): IService; restangularizeElement(parent: any, element: any, route: string, collection?: any, reqParams?: any): IElement; restangularizeCollection(parent: any, element: any, route: string): ICollection; service(route: string, parent?: any): IService; stripRestangular(element: any): any; extendModel(route: string, extender: (model: IElement) => any): void; } interface IElement extends IService { get(queryParams?: any, headers?: any): IPromise; get(queryParams?: any, headers?: any): IPromise; getList(subElement?: any, queryParams?: any, headers?: any): ICollectionPromise; getList(subElement?: any, queryParams?: any, headers?: any): ICollectionPromise; put(queryParams?: any, headers?: any): IPromise; post(subElement: any, elementToPost: any, queryParams?: any, headers?: any): IPromise; post(subElement: any, elementToPost: T, queryParams?: any, headers?: any): IPromise; post(elementToPost: any, queryParams?: any, headers?: any): IPromise; post(elementToPost: T, queryParams?: any, headers?: any): IPromise; remove(queryParams?: any, headers?: any): IPromise; head(queryParams?: any, headers?: any): IPromise; trace(queryParams?: any, headers?: any): IPromise; options(queryParams?: any, headers?: any): IPromise; patch(queryParams?: any, headers?: any): IPromise; clone(): IElement; plain(): any; plain(): T; withHttpConfig(httpConfig: angular.IRequestShortcutConfig): IElement; save(queryParams?: any, headers?: any): IPromise; getRestangularUrl(): string; } interface ICollection extends IService, Array { getList(queryParams?: any, headers?: any): ICollectionPromise; getList(queryParams?: any, headers?: any): ICollectionPromise; post(elementToPost: any, queryParams?: any, headers?: any): IPromise; post(elementToPost: T, queryParams?: any, headers?: any): IPromise; head(queryParams?: any, headers?: any): IPromise; trace(queryParams?: any, headers?: any): IPromise; options(queryParams?: any, headers?: any): IPromise; patch(queryParams?: any, headers?: any): IPromise; putElement(idx: any, params: any, headers: any): IPromise; withHttpConfig(httpConfig: angular.IRequestShortcutConfig): ICollection; clone(): ICollection; plain(): any; plain(): T[]; getRestangularUrl(): string; } }