1.0.0 • Published 4 years ago

@inclouded/lavinia-sdk v1.0.0

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

Lavinia Api SDK

Bevezető

A repository-ban az LaviniaApi SDK található egy telepíthető Angular könyvtár formájában. Az SDK telepíthető minden Angular 2+ projekthez. Az SDK megvalósítja a szükséges CRUD műveleteket.

Használata

  1. Az SDK használatához szükséges egy Angular 2+ projekt.

  2. A hozzá kapcsolódó interface-ek (User.ts, Device.ts, LaviniaDAO.ts):

export class User {
    _id: string;
    className: string;
    email: string;
    fullname: string;
    active: boolean;
    comment: string;
    password: string;
    type: string;
}

export class Device {
    _id: string;
    className: string;
    name: string;
    description: string;
    owner: string;
    hwId: string;
    acls: string;
}

export interface LaviniaDAO {
    httpClient: HttpClient;
    url: string;
}

export enum ClassName {
    user = 'model.User',
    device = 'model.Device',
}

export enum UserType {
    admin = 'admin',
    user = 'user'
}
  1. Egy Service-ben felhasználható az SDK, az alábbi módon:
import { Injectable } from '@angular/core';
import { LaviniaApi, documentType, LaviniaDAO } from '@inclouded/lavinia-sdk';
import { HttpClient } from '@angular/common/http';

@Injectable()
export class LaviniaApiService {

  LaviniaApi: LaviniaApi;
  LaviniaDAO: LaviniaDAO = {
   httpClient: this.http,
   url: 'https://url.hu'
  };
  collectionName = 'collectionName';
  documentType = documentType;

  constructor(private http: HttpClient) {
    this.LaviniaApi = new LaviniaApi(this.LaviniaDAO, this.collectionName, this.documentType);
  }

  add(data: any) {
    return this.LaviniaApi.add(data);
  }

  delete(id: string) {
    return this.LaviniaApi.delete(id);
  }

  update(data: any, id: string) {
    return this.LaviniaApi.delete(data, id);
  }
}

Felelős fejlesztő: Simon Gábor (simonovszkij@gmail.com)