1414 * limitations under the License.
1515 */
1616
17- import { ClientResponse } from 'http' ;
1817import { from as observableFrom , Observable , throwError } from 'rxjs' ;
1918import { catchError , map } from 'rxjs/operators' ;
2019import { AccountInfo } from '../model/account/AccountInfo' ;
@@ -27,8 +26,7 @@ import {Transaction} from '../model/transaction/Transaction';
2726import { UInt64 } from '../model/UInt64' ;
2827import { AccountRepository } from './AccountRepository' ;
2928import { AccountInfoDTO ,
30- AccountRoutesApi ,
31- TransactionInfoDTO } from './api' ;
29+ AccountRoutesApi } from './api' ;
3230import { Http } from './Http' ;
3331import { NetworkHttp } from './NetworkHttp' ;
3432import { QueryParams } from './QueryParams' ;
@@ -64,31 +62,28 @@ export class AccountHttp extends Http implements AccountRepository {
6462 */
6563 public getAccountInfo ( address : Address ) : Observable < AccountInfo > {
6664 return observableFrom ( this . accountRoutesApi . getAccountInfo ( address . plain ( ) ) ) . pipe (
67- map ( ( response : { response : ClientResponse ; body : AccountInfoDTO ; } ) => {
68- const accountInfoDTO = response . body ;
69- return new AccountInfo (
70- Address . createFromEncoded ( accountInfoDTO . account . address ) ,
71- UInt64 . fromNumericString ( accountInfoDTO . account . addressHeight ) ,
72- accountInfoDTO . account . publicKey ,
73- UInt64 . fromNumericString ( accountInfoDTO . account . publicKeyHeight ) ,
74- accountInfoDTO . account . accountType . valueOf ( ) ,
75- accountInfoDTO . account . linkedAccountKey ,
76- accountInfoDTO . account . activityBuckets . map ( ( bucket ) => {
65+ map ( ( { body} ) => new AccountInfo (
66+ Address . createFromEncoded ( body . account . address ) ,
67+ UInt64 . fromNumericString ( body . account . addressHeight ) ,
68+ body . account . publicKey ,
69+ UInt64 . fromNumericString ( body . account . publicKeyHeight ) ,
70+ body . account . accountType . valueOf ( ) ,
71+ body . account . linkedAccountKey ,
72+ body . account . activityBuckets . map ( ( bucket ) => {
7773 return new ActivityBucket (
7874 bucket . startHeight ,
7975 bucket . totalFeesPaid ,
8076 bucket . beneficiaryCount ,
8177 bucket . rawScore ,
8278 ) ;
8379 } ) ,
84- accountInfoDTO . account . mosaics . map ( ( mosaicDTO ) => new Mosaic (
80+ body . account . mosaics . map ( ( mosaicDTO ) => new Mosaic (
8581 new MosaicId ( mosaicDTO . id ) ,
8682 UInt64 . fromNumericString ( mosaicDTO . amount ) ,
8783 ) ) ,
88- UInt64 . fromNumericString ( accountInfoDTO . account . importance ) ,
89- UInt64 . fromNumericString ( accountInfoDTO . account . importanceHeight ) ,
90- ) ;
91- } ) ,
84+ UInt64 . fromNumericString ( body . account . importance ) ,
85+ UInt64 . fromNumericString ( body . account . importanceHeight ) ,
86+ ) ) ,
9287 catchError ( ( error ) => throwError ( this . errorHandling ( error ) ) ) ,
9388 ) ;
9489 }
@@ -104,9 +99,7 @@ export class AccountHttp extends Http implements AccountRepository {
10499 } ;
105100 return observableFrom (
106101 this . accountRoutesApi . getAccountsInfo ( accountIdsBody ) ) . pipe (
107- map ( ( response : { response : ClientResponse ; body : AccountInfoDTO [ ] ; } ) => {
108- const accountsInfoMetaDataDTO = response . body ;
109- return accountsInfoMetaDataDTO . map ( ( accountInfoDTO : AccountInfoDTO ) => {
102+ map ( ( { body} ) => body . map ( ( accountInfoDTO : AccountInfoDTO ) => {
110103 return new AccountInfo (
111104 Address . createFromEncoded ( accountInfoDTO . account . address ) ,
112105 UInt64 . fromNumericString ( accountInfoDTO . account . addressHeight ) ,
@@ -130,8 +123,7 @@ export class AccountHttp extends Http implements AccountRepository {
130123 UInt64 . fromNumericString ( accountInfoDTO . account . importanceHeight ) ,
131124 ) ;
132125
133- } ) ;
134- } ) ,
126+ } ) ) ,
135127 catchError ( ( error ) => throwError ( this . errorHandling ( error ) ) ) ,
136128 ) ;
137129 }
@@ -148,12 +140,9 @@ export class AccountHttp extends Http implements AccountRepository {
148140 this . queryParams ( queryParams ) . pageSize ,
149141 this . queryParams ( queryParams ) . id ,
150142 this . queryParams ( queryParams ) . order ) ) . pipe (
151- map ( ( response : { response : ClientResponse ; body : TransactionInfoDTO [ ] ; } ) => {
152- const transactionsDTO = response . body ;
153- return transactionsDTO . map ( ( transactionDTO ) => {
143+ map ( ( { body} ) => body . map ( ( transactionDTO ) => {
154144 return CreateTransactionFromDTO ( transactionDTO ) ;
155- } ) ;
156- } ) ,
145+ } ) ) ,
157146 catchError ( ( error ) => throwError ( this . errorHandling ( error ) ) ) ,
158147 ) ;
159148 }
@@ -171,12 +160,9 @@ export class AccountHttp extends Http implements AccountRepository {
171160 this . queryParams ( queryParams ) . pageSize ,
172161 this . queryParams ( queryParams ) . id ,
173162 this . queryParams ( queryParams ) . order ) ) . pipe (
174- map ( ( response : { response : ClientResponse ; body : TransactionInfoDTO [ ] ; } ) => {
175- const transactionsDTO = response . body ;
176- return transactionsDTO . map ( ( transactionDTO ) => {
163+ map ( ( { body} ) => body . map ( ( transactionDTO ) => {
177164 return CreateTransactionFromDTO ( transactionDTO ) ;
178- } ) ;
179- } ) ,
165+ } ) ) ,
180166 catchError ( ( error ) => throwError ( this . errorHandling ( error ) ) ) ,
181167 ) ;
182168 }
@@ -194,12 +180,9 @@ export class AccountHttp extends Http implements AccountRepository {
194180 this . queryParams ( queryParams ) . pageSize ,
195181 this . queryParams ( queryParams ) . id ,
196182 this . queryParams ( queryParams ) . order ) ) . pipe (
197- map ( ( response : { response : ClientResponse ; body : TransactionInfoDTO [ ] ; } ) => {
198- const transactionsDTO = response . body ;
199- return transactionsDTO . map ( ( transactionDTO ) => {
183+ map ( ( { body} ) => body . map ( ( transactionDTO ) => {
200184 return CreateTransactionFromDTO ( transactionDTO ) ;
201- } ) ;
202- } ) ,
185+ } ) ) ,
203186 catchError ( ( error ) => throwError ( this . errorHandling ( error ) ) ) ,
204187 ) ;
205188 }
@@ -218,12 +201,9 @@ export class AccountHttp extends Http implements AccountRepository {
218201 this . queryParams ( queryParams ) . pageSize ,
219202 this . queryParams ( queryParams ) . id ,
220203 this . queryParams ( queryParams ) . order ) ) . pipe (
221- map ( ( response : { response : ClientResponse ; body : TransactionInfoDTO [ ] ; } ) => {
222- const transactionsDTO = response . body ;
223- return transactionsDTO . map ( ( transactionDTO ) => {
204+ map ( ( { body} ) => body . map ( ( transactionDTO ) => {
224205 return CreateTransactionFromDTO ( transactionDTO ) ;
225- } ) ;
226- } ) ,
206+ } ) ) ,
227207 catchError ( ( error ) => throwError ( this . errorHandling ( error ) ) ) ,
228208 ) ;
229209 }
@@ -241,12 +221,9 @@ export class AccountHttp extends Http implements AccountRepository {
241221 this . queryParams ( queryParams ) . pageSize ,
242222 this . queryParams ( queryParams ) . id ,
243223 this . queryParams ( queryParams ) . order ) ) . pipe (
244- map ( ( response : { response : ClientResponse ; body : TransactionInfoDTO [ ] ; } ) => {
245- const transactionsDTO = response . body ;
246- return transactionsDTO . map ( ( transactionDTO ) => {
224+ map ( ( { body} ) => body . map ( ( transactionDTO ) => {
247225 return CreateTransactionFromDTO ( transactionDTO ) as AggregateTransaction ;
248- } ) ;
249- } ) ,
226+ } ) ) ,
250227 catchError ( ( error ) => throwError ( this . errorHandling ( error ) ) ) ,
251228 ) ;
252229 }
0 commit comments