Skip to content

Commit

Permalink
code4romania#39: Added address endpoints to assets.service
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanmosica committed Apr 4, 2019
1 parent 24a82bd commit 177def0
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/app/core/services/assets.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import * as fromSelectors from '../store/selectors';

import { AssetsApiService } from '../http';
import {
Address,
AddressResponse,
Asset,
AssetCurrency,
AssetDetailResponse,
Expand Down Expand Up @@ -55,6 +57,28 @@ export class AssetsService {
);
}

public createAddress(aAddress: Address): Observable<Address> {
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<Address> {
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<AssetMeasurement[]> {
const measurements = [
new AssetMeasurement({ id: 'buc', code: 'Bucati' }),
Expand Down Expand Up @@ -93,7 +117,6 @@ export class AssetsService {
theAsset.setCategory(aCategory);
theAsset.setSubcategory(aSubcategory);
theAsset.setStage(aStage);

return theAsset;
}
).pipe(
Expand Down

0 comments on commit 177def0

Please sign in to comment.