Skip to content

Commit

Permalink
Merge pull request #106 from mysteriumnetwork/improvements/settlement…
Browse files Browse the repository at this point in the history
…-history

Settlement response now has `withdrawalTotal`
  • Loading branch information
mdomasevicius authored Dec 16, 2021
2 parents 009df3a + f5a7342 commit dae47e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/tequilapi-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
SettlementListResponse,
Settlement,
BeneficiaryTxStatus,
validateSettlementResponse,
} from './transactor/settlement'
import { IdentityCurrentRequest } from './identity/selection'
import { AuthRequest, AuthResponse, ChangePasswordRequest } from './auth/auth'
Expand Down Expand Up @@ -547,7 +548,7 @@ class BaseHttpTequilapiClient implements BaseTequilapiClient {
if (!response) {
throw new Error('Settlement history response body is missing')
}
return parsePageable<Settlement>(response)
return validateSettlementResponse<SettlementListResponse>(response)
}

public async getMMNNodeReport(): Promise<MMNReportResponse> {
Expand Down
14 changes: 12 additions & 2 deletions src/transactor/settlement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import { Pageable, PaginationQuery } from '../common/pageable'
import { Pageable, PaginationQuery, parsePageable } from '../common/pageable'
import { validate } from '../fmt/validation'

export interface SettleRequest {
hermesId: string
Expand Down Expand Up @@ -42,7 +43,11 @@ export interface SettlementListQuery extends PaginationQuery {
hermesId?: string
}

export type SettlementListResponse = Pageable<Settlement>
export interface SettlementStats {
withdrawalTotal?: string
}

export type SettlementListResponse = Pageable<Settlement> & SettlementStats

export enum BeneficiaryTxState {
COMPLETED = 'completed',
Expand All @@ -53,3 +58,8 @@ export interface BeneficiaryTxStatus {
state: BeneficiaryTxState
error: string
}

export const validateSettlementResponse = <T>(response: any): any => {
validate('SettlementListResponse', response, { name: 'withdrawalTotal', type: 'string' })
return parsePageable<T>(response)
}

0 comments on commit dae47e1

Please sign in to comment.