From 177def071db5e81ab4738b48b56e08afa3419806 Mon Sep 17 00:00:00 2001 From: Wydder Date: Thu, 4 Apr 2019 23:44:42 +0300 Subject: [PATCH] #39: Added address endpoints to assets.service --- src/app/core/services/assets.service.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/app/core/services/assets.service.ts b/src/app/core/services/assets.service.ts index 14b453d..019dac2 100644 --- a/src/app/core/services/assets.service.ts +++ b/src/app/core/services/assets.service.ts @@ -8,6 +8,8 @@ import * as fromSelectors from '../store/selectors'; import { AssetsApiService } from '../http'; import { + Address, + AddressResponse, Asset, AssetCurrency, AssetDetailResponse, @@ -55,6 +57,28 @@ export class AssetsService { ); } + public createAddress(aAddress: Address): Observable
{ + return this.assetsApiService.createAddress(aAddress.getAssetId(), aAddress.toJson()) + .pipe( + map((aNewAddress: AddressResponse) => { + const theAddress = new Address(aNewAddress); + theAddress.setAsset(aAddress.getAsset()); + return theAddress; + }) + ); + } + + public updateAddress(aAddress: Address): Observable
{ + return this.assetsApiService.updateAddress(aAddress.getAssetId(), aAddress.toJson()) + .pipe( + map((aNewAddress: AddressResponse) => { + const theAddress = new Address(aNewAddress); + theAddress.setAsset(aAddress.getAsset()); + return theAddress; + }) + ); + } + public measurements(): Observable { const measurements = [ new AssetMeasurement({ id: 'buc', code: 'Bucati' }), @@ -93,7 +117,6 @@ export class AssetsService { theAsset.setCategory(aCategory); theAsset.setSubcategory(aSubcategory); theAsset.setStage(aStage); - return theAsset; } ).pipe(