1.0.4 • Published 6 years ago
@dots-connect-it/api v1.0.4
Dots API
This package contain service which should be inherited by another services for use default methods in each dots project.
Usage
Create service
ng g s car-apiCreate interface
export interface Car {
id: number;
name: string;
color: string;
}Extend API service
Extends ApiService and indicate right endpoint.
import { ApiService } from '@dancornilov/api';
export class CarApiService extends ApiService<Car> {
protected endpoint = 'car';
}Interfaces
export interface ApiIndexResult<T> {
data: T[];
pagination: Paginator;
}
export interface ApiSingleResult<T> {
data: T;
}Methods
| Method | Description | Value |
|---|---|---|
| index | Get whole list of entities | Observable<ApiIndexResult> |
| create | Create new entity | Observable |
| update | Update already existent entity | Observable |
| get | Get entity by dataKey(id) | Observable<ApiSingleResult> |
| patch | Update some properties from existent entity | Observable |
| list | Get serialized list of entities (key/value) | Observable |