exc-rest
v1.0.8
Published
ExcRestModule implements the ExcRestService.
Downloads
9
Readme
Documentation
Module Exc-Rest
ExcRestModule implements the ExcRestService.
Setup
To use ExcRestService you have to do preparations in your project.
- Ensure that the exc-core module is included as dependency in package.json
- Ensure that the exc-rest module is included as dependency in package.json
- Setup app.module.ts file
import {environment} from '../environments/environment';
import {HttpClient, HttpClientModule} from '@angular/common/http';
import {ExcCoreModule} from 'exc-core';
import {ExcRestModule} from 'exc-rest';
//...
@NgModule({
declarations:[],
imports:[
HttpClientModule
ExcRestModule
//...
],
entryComponents:[],
providers:[],
bootstrap: [AppComponent]
})
export class AppModule{
env = environment
constuctor(){
ExcCoreModule.RegisterConfig('Environment',_self.env);
}
//...
}
- Setup app.component.ts file
import {ExcCoreModule} from 'exc-core';
import {ExcRestModule} from 'exc-rest';
//...
export class AppComponent implements OnInit{
//...
constructor(private excRestService:ExcRestService){
}
}
ExcRestService
The ExcRestService is the service for standard communication with the EXCON REST Apis.
Parameter definition
name
Defines the name of the endpoint in environment.ts under Endpoints.pObj
Defines an object for replacement of placeholders in URLurl
Defines the url generated by computedUrldata
Defines the data that will be sent to the webserviceconf
Defines the http config used by rest call. Detailed information under this paragraphisbc
Defines a call is a background call or not. It is used for global activity indicator. Background calls doesn't have an effect to indicator.fullResponse
Used by delete and put. By default these methods return the fullResponse. If you use this function please manually set parameter to false. The default behavior will be set to false in future.
Config object
MetaInfo:*object*
Defines the definition for filter, paging and sorting for webservice.OnProgress(progress):*function*
Method that could be set to get information about progress of the call.export:*Boolean*
If set to true the call is marked as download and the webservice result is downloaded as file.
Members
Methods
Publics
All public methods have a default behavior. So the automatically triggers messages for success and error or are preprocessing data.
|Method|Return|Description| | --- | --- | --- | | computeUrl(name:string,pObj:object)|string|Gets a computed url from config and replaces placeholders with values of pObj| | delete(url:string,data:any,conf:object,fullResponse:Boolean(true))|Observable|Sends an HTTP DELETE request to given URL| | get(url:string,conf:object)|Observable|Sends an HTTP GET request to given URL| | sget(url:string,id:string,conf:object)|Observable|Sends an HTTP GET request to given URL. The given ID is used to identify the last call of an id. So it is possible to get the last valid call. At response you can check the flag valid to only use the last answer for the given id | | post(url:string,data:any,conf:object)|Observable|Sends an HTTP POST request to given URL| | put(url:string,data:any,conf:object,fullResponse:Boolean(true))|Observable|Sends an HTTP PUT request to given URL| | base64ToArrayBuffer(base64:string)|Uint8Array|Convert a base64 string to an arraybuffer| | exportBase64(base64String:string,contentType:string,filename:string)|void|starts a download of the base64 string with given contentType and filename| | exportBuffer(uInt8Array:Uint8Array,contentType:string,filename:string)|void|starts a download of the UInt8Array with given contentType and filename|
Internals
Internal call shouldn't be used for default behavior. The internal methods have no default behavior.
|Method|Return|Description| | --- | --- | --- | | _deleteInternal(url:string,data:any,conf:object,isbc:Boolean)|Observable|Sends an HTTP DELETE request to given URL| | _getInternal(url:string,conf:object,isbc:Boolean)|Observable|Sends an HTTP GET request to given URL| | _putInternal(url:string,data:any,conf:object,isbc:Boolean)|Observable|Sends an HTTP PUT request to given URL| | _postInternal(url:string,data:any,conf:object,isbc:Boolean)|Observable|Sends an HTTP POST request to given URL|
get example
import {ExcCoreModule} from './exc-core.module';
const excRest = ExcCoreModule.Services().ExcRest;
// OrderList: {uid}/order/:ordID
let obs = excRest.get(excRest.computeUrl('OrderDetails',{ordID:14}),{MetaInfo:{}});
obs.subscribe(result=>{
//doIt
})
sget example
import {ExcCoreModule} from './exc-core.module';
const excRest = ExcCoreModule.Services().ExcRest;
// OrderList: {uid}/order
let obs = excRest.sget(excRest.computeUrl('OrderList',{key:'value',fts:'full-text-search-value'}),'MagicList',{MetaInfo:{}});
obs.subscribe(result=>{
if(result.valid)
{
//doIt
}
})