0.0.10 • Published 4 years ago

vishwam-camera-lib-angular v0.0.10

Weekly downloads
41
License
-
Repository
-
Last release
4 years ago

vishwam-camera-lib-angular

Vishwam Camera module for angular project

Installation

npm install vishwam-camera-lib-angular

Usage

Import vishwam module in app.modules.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import {VishwamModule} from 'vishwam-camera-lib-angular';

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    VishwamModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Add the lib-vishwam selector in component HTML file

<lib-vishwam></lib-vishwam>

Import Vishwam Service in your component TS file

Import Vishwam Service and use the startCamera() method, It will return a JSON response.

The method startCamera() accepts two parameters
1. domain: 
    Vishwam backend domain URL - string
2. referenceId:
    Reference Id of the transaction - string
The method makeRequest accepts four parameters
1. imageData: 
    Base64 encoded image data - string
    
2. contentType: 
    MimeType of the image
    ex: "image/png" or "image/jpeg", ("image/png" is preferred)
    
3. domain: 
    Vishwam backend domain URL - string

4. referenceId:
    Reference Id of the transaction - string

Example:

import { Component, OnInit } from '@angular/core';
import { VishwamService } from 'vishwam-camera-lib-angular';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {

  constructor(private vishwam: VishwamService) { }

  ngOnInit() {
  }
  
  // To Open camera, capture image, and make request
  async openCamera() {
    const response = await this.vishwam.startCamera("https://test-domain.example.com", "test26739994");

  }

  // To make request to vishwam using image
  async makeRequestToVishwam() {
    const response = await this.vishwam.makeRequest(imageData, contentType, "https://test-domain.example.com", "test27781763");
    
  }


}
0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago