mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #990 from santialbo/restangular-fix
Fix Restangular type definitions
This commit is contained in:
@@ -88,6 +88,10 @@ function test_config() {
|
||||
RestangularProvider.setDefaultHttpFields({ cache: true });
|
||||
RestangularProvider.setMethodOverriders(["put", "patch"]);
|
||||
|
||||
RestangularProvider.setErrorInterceptor(function (response) {
|
||||
console.error('' + response.status + ' ' + response.data);
|
||||
});
|
||||
|
||||
RestangularProvider.setRestangularFields({
|
||||
id: "_id",
|
||||
route: "restangularRoute"
|
||||
@@ -102,4 +106,33 @@ function test_config() {
|
||||
elem.accountName = 'Changed';
|
||||
return elem;
|
||||
});
|
||||
|
||||
var myRestangular = Restangular.withConfig((configurer: RestangularProvider) => {
|
||||
configurer.setBaseUrl('/api/v1');
|
||||
configurer.setExtraFields(['name']);
|
||||
|
||||
configurer.setErrorInterceptor(function (response) {
|
||||
console.error('' + response.status + ' ' + response.data);
|
||||
});
|
||||
configurer.setResponseExtractor(function (response, operation) {
|
||||
return response.data;
|
||||
});
|
||||
configurer.setDefaultHttpFields({ cache: true });
|
||||
configurer.setMethodOverriders(["put", "patch"]);
|
||||
|
||||
configurer.setRestangularFields({
|
||||
id: "_id",
|
||||
route: "restangularRoute"
|
||||
});
|
||||
|
||||
configurer.setRequestSuffix('.json');
|
||||
|
||||
configurer.setRequestInterceptor(function (element, operation, route, url) {
|
||||
});
|
||||
|
||||
configurer.addElementTransformer('accounts', false, function (elem) {
|
||||
elem.accountName = 'Changed';
|
||||
return elem;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+13
-3
@@ -56,11 +56,11 @@ interface RestangularProvider {
|
||||
addElementTransformer(route: string, transformer: Function): void;
|
||||
addElementTransformer(route: string, isCollection: boolean, transformer: Function): void;
|
||||
setOnElemRestangularized(callback: (elem: any, isCollection: boolean, what: string, restangular: Restangular) => any): void;
|
||||
setResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: XMLHttpRequest, deferred: ng.IDeferred<any>) => any): void;
|
||||
setResponseExtractor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: XMLHttpRequest, deferred: ng.IDeferred<any>) => any): void;
|
||||
setResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: RestangularResponse, deferred: ng.IDeferred<any>) => any): void;
|
||||
setResponseExtractor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: RestangularResponse, deferred: ng.IDeferred<any>) => any): void;
|
||||
setRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any);
|
||||
setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any) => {element: any; headers: any; params: any});
|
||||
setErrorInterceptor(errorInterceptor: (response: XMLHttpRequest) => any): void;
|
||||
setErrorInterceptor(errorInterceptor: (response: RestangularResponse) => any): void;
|
||||
setRestangularFields(fields: {[fieldName: string]: string}): void;
|
||||
setMethodOverriders(overriders: string[]): void;
|
||||
setDefaultRequestParams(params: any): void;
|
||||
@@ -71,5 +71,15 @@ interface RestangularProvider {
|
||||
setUseCannonicalId(useCannonicalId: boolean): void;
|
||||
}
|
||||
|
||||
interface RestangularResponse {
|
||||
status: number;
|
||||
data: any;
|
||||
config: {
|
||||
method: string;
|
||||
url: string;
|
||||
params: any;
|
||||
}
|
||||
}
|
||||
|
||||
declare var Restangular: Restangular;
|
||||
declare var RestangularProvider: RestangularProvider;
|
||||
|
||||
Reference in New Issue
Block a user