npm package: @kimaya-hybrid/ngx-http-service
Description: This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.1.0.
Latest version: 1.0.4

# HttpHandler

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.1.0.

## How Install
    npm install @kimaya-hybrid/ngx-http-service

#### Dependency 
<code>*You need to install dependencies manually*</code> 

[CookieStorage](https://www.npmjs.com/package/@kimaya-hybrid/ngx-cookie-storage)
this is being used to store all cookies in this library.<br>
[AuthService](https://www.npmjs.com/package/@kimaya-hybrid/ngx-auth-service)
this is being used for checking and fetching auth related settings.


## Plug into your application

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { AppComponent } from './app.component';
    import { HttpServiceModule } from 'ngx-http-service';
    
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        HttpServiceModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

 
 ## How to use
 
 Inject into your <code>Component</code> or <code>Service</code>.
        
        import { Component } from '@angular/core';
        import { HttpService } from 'ngx-http-service';
        
        @Component({
          selector: 'app-root',
          templateUrl: './app.component.html',
          styleUrls: ['./app.component.scss']
        })
        
        export class AppComponent {
          constructor(private httpService: HttpService) {
          }
        }
        


 ## HttpService Configure
 
 User can configure some of keys for auth service as per project requirements.
   
 User need to set <code>HttpServiceConstants</code> keys for usages.
 
 *Need to set <code>serverUrl</code> .This will be used to hit api using httpService used as host for all default api*
 
 <code>ServerUrl is host </code><br>
 
 | Keys | Required | Default Value| Usage|
 |-------------|-------------|-----|-----|
 | serverUrl | true | null | used to store default host for all api end point which passed to HttpService functions |
 | headers | false | {} | Provide extra headers for all Http request including multipart request |

<br>

## Methods
        
#### get(endPoint: string, params?: object, body?: object, contentType?: string, backendUrl?: string ): Observable<any>;
        this.httpService.get(endPoint).subscribe();
to call http get method. In this method service will automatically append serverUrl from constant (host) and endPoint parameter.<br>
* endPoint: http api end point without host
* params: to set in param header [optional]
* body: to set in body header [optional]
* contentType: to set in content type header [optional]
* backendUrl: if you want to change host pass this parament [optional]
<hr>
     
#### getFromUrl(url: string, params?: object, body?: object, contentType?: string): Observable<any>;
        this.httpService.getFromUrl(endPoint).subscribe();
to call http get method. In this method service will not append serverUrl from constant (host) and will hit api based url you pass.<br>
* url: http api url with host and end point 
* params: to set in param header [optional]
* body: to set in body header [optional]
* contentType: to set in content type header [optional]
<hr>

#### getFromUrlWithoutHeader(url: string): Observable<any>;
        this.httpService.getFromUrlWithoutHeader(url).subscribe();
to call http get method. In this method, service will not add default header setting for http call.<br>
* url: http api url with host and end point 
* headers: HttpHeader- Custom Headers can be added. 
<hr>
        
#### post(endPoint: string, requestBody: object, params?: object, body?: object, contentType?: string, backendUrl?: string ): Observable<any>;
        this.httpService.post(endPoint, requestBody).subscribe();
to call http post method. In this method service will automatically append serverUrl from constant (host) and endPoint parameter.<br>
* endPoint: http api end point without host
* requestBody: request body in json
* params: to set in param header [optional]
* body: to set in body header [optional]
* contentType: to set in content type header [optional]
* backendUrl: if you want to change host pass this
parameter [optional]
<hr>
     
#### postFromUrl(url: string, requestBody: object, params?: object, body?: object, contentType?: string): Observable<any>;
        this.httpService.postFromUrl(url, requestBody).subscribe();
to call http post method. In this method service will not append serverUrl from constant (host) and will hit api based url you pass.<br>
* url: http api url with host and end point 
* requestBody: request body in json
* params: to set in param header [optional]
* body: to set in body header [optional]
* contentType: to set in content type header [optional]
<hr>

#### postFromUrlWithoutHeader(url: string, requestBody: object): Observable<any>;
        this.httpService.postFromUrlWithoutHeader(url, requestBody).subscribe();
to call http post method. In this method, service will not add default header setting for http call.<br>
* url: http api url with host and end point 
* requestBody: request body in json 
* headers: HttpHeader- Custom Headers can be added. 

<hr>
   
#### put(endPoint: string, requestBody: object, params?: object, body?: object, contentType?: string, backendUrl?: string ): Observable<any>;
        this.httpService.put(endPoint, requestBody).subscribe();
to call http put method. In this method service will automatically append serverUrl from constant (host) and endPoint parameter.<br>
* endPoint: http api end point without host
* requestBody: request body in json
* params: to set in param header [optional]
* body: to set in body header [optional]
* contentType: to set in content type header [optional]
* backendUrl: if you want to change host pass this
parameter [optional]
<hr>
     
#### putFromUrl(url: string, requestBody: object, params?: object, body?: object, contentType?: string): Observable<any>;
        this.httpService.putFromUrl(url, requestBody).subscribe();
to call http put method. In this method service will not append serverUrl from constant (host) and will hit api based url you pass.<br>
* url: http api url with host and end point 
* requestBody: request body in json
* params: to set in param header [optional]
* body: to set in body header [optional]
* contentType: to set in content type header [optional]
<hr>

#### putFromUrlWithoutHeader(url: string, requestBody: object): Observable<any>;
        this.httpService.putFromUrlWithoutHeader(url, requestBody).subscribe();
to call http put method. In this method, service will not add default header setting for http call.<br>
* url: http api url with host and end point 
* requestBody: request body in json
* headers: HttpHeader- Custom Headers can be added. 
<hr>

#### delete(endPoint: string, params?: object, body?: object, contentType?: string, backendUrl?: string ): Observable<any>;
        this.httpService.delete(endPoint).subscribe();
to call http delete method. In this method service will automatically append serverUrl from constant (host) and endPoint parameter.<br>
* endPoint: http api end point without host
* params: to set in param header [optional]
* body: to set in body header [optional]
* contentType: to set in content type header [optional]
* backendUrl: if you want to change host pass this
parameter [optional]
<hr>
     
#### deleteFromUrl(url: string, params?: object, body?: object, contentType?: string): Observable<any>;
        this.httpService.deleteFromUrl(endPoint).subscribe();
to call http delete method. In this method service will not append serverUrl from constant (host) and will hit api based url you pass.<br>
* url: http api url with host and end point 
* params: to set in param header [optional]
* body: to set in body header [optional]
* contentType: to set in content type header [optional]
<hr>

#### deleteFromUrlWithoutHeader(url: string): Observable<any>;
        this.httpService.deleteFromUrlWithoutHeader(url).subscribe();
to call http delete method. In this method, service will not add default header setting for http call.<br>
* url: http api url with host and end point 
* headers: HttpHeader- Custom Headers can be added. 
<hr>

#### multipart(endPoint: string, formData: FormData, methodType: HttpMethodTypes = HttpMethodTypes.GET, backendUrl?: string, responseType: HttpResponseTypes = HttpResponseTypes.json, authKey: string = 'Authorization'): Observable<any>;
        this.httpService.multipart(endPoint, formData).subscribe();
to call http method for multipart. In this method service will automatically append serverUrl from constant (host) and endPoint parameter.<br>
* endPoint: string 
* formData: FormData 
* methodType: HttpMethodTypes = HttpMethodTypes.GET // default get method
* backendUrl: string [optional]
* responseType: HttpResponseTypes = HttpResponseTypes.json // default JSON type
* httpHeaders: HttpHeader = null // default null
* authKey: string = 'Authorization' 
<hr>

#### multipartFromUrl(url: string, formData: FormData, methodType: HttpMethodTypes = HttpMethodTypes.GET, backendUrl: string, responseType: HttpResponseTypes = HttpResponseTypes.json, authKey: string = 'Authorization'): Observable<any>;
        this.httpService.multipartFromUrl(endPoint, formData).subscribe();
to call http method for multipart. In this method, service will not add default header setting for http call.<br>
* url: string 
* formData: FormData 
* methodType: HttpMethodTypes = HttpMethodTypes.GET // default get method
* responseType: HttpResponseTypes = HttpResponseTypes.json // default JSON type
* httpHeaders: HttpHeader = null // default null
* authKey: string = 'Authorization' 
<hr>

## Enums
We can use this enum values to pass parameters for multipart methods.

#### HttpResponseTypes
    enum HttpResponseTypes {
      'blob' = 'blob',
      'json' = 'json',
      'arraybuffer' = 'arraybuffer'
    }
    
#### HttpMethodTypes
    enum HttpMethodTypes {
      'GET' = 'GET',
      'POST' = 'POST',
      'PUT' = 'PUT'
    }  


## For more Information 
you can contact on <code>kumarganesh088@gmail.com</code>