2021-04-23 19:43:23 +01:00
|
|
|
// Copyright (C) 2021 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
import { PayoutsClient } from '@/api/payouts';
|
2021-05-31 16:40:04 +01:00
|
|
|
import { Expectation, HeldAmountSummary, PayoutsSummary, Paystub } from '@/payouts/index';
|
2021-04-23 19:43:23 +01:00
|
|
|
|
|
|
|
/**
|
2021-05-31 16:40:04 +01:00
|
|
|
* Exposes all payouts related logic
|
2021-04-23 19:43:23 +01:00
|
|
|
*/
|
|
|
|
export class Payouts {
|
|
|
|
private readonly payouts: PayoutsClient;
|
|
|
|
|
|
|
|
public constructor(payouts: PayoutsClient) {
|
|
|
|
this.payouts = payouts;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-05-31 16:40:04 +01:00
|
|
|
* Fetches payouts summary information.
|
2021-04-23 19:43:23 +01:00
|
|
|
*
|
|
|
|
* @param satelliteId - satellite id.
|
|
|
|
* @param period - selected period.
|
|
|
|
*
|
|
|
|
* @throws {@link BadRequestError}
|
|
|
|
* This exception is thrown if the input is not a valid.
|
|
|
|
*
|
|
|
|
* @throws {@link UnauthorizedError}
|
|
|
|
* Thrown if the auth cookie is missing or invalid.
|
|
|
|
*
|
|
|
|
* @throws {@link InternalError}
|
|
|
|
* Thrown if something goes wrong on server side.
|
|
|
|
*/
|
|
|
|
public async summary(satelliteId: string | null, period: string | null): Promise<PayoutsSummary> {
|
2021-04-30 10:33:36 +01:00
|
|
|
return await this.payouts.summary(satelliteId, period);
|
2021-04-23 19:43:23 +01:00
|
|
|
}
|
2021-05-21 16:28:49 +01:00
|
|
|
|
|
|
|
/**
|
2021-05-31 16:40:04 +01:00
|
|
|
* Fetches payouts expectation such as estimated current month payout and undistributed payout.
|
2021-05-21 16:28:49 +01:00
|
|
|
*
|
|
|
|
* @param nodeId - node id.
|
|
|
|
*
|
|
|
|
* @throws {@link BadRequestError}
|
|
|
|
* This exception is thrown if the input is not a valid.
|
|
|
|
*
|
|
|
|
* @throws {@link UnauthorizedError}
|
|
|
|
* Thrown if the auth cookie is missing or invalid.
|
|
|
|
*
|
|
|
|
* @throws {@link InternalError}
|
|
|
|
* Thrown if something goes wrong on server side.
|
|
|
|
*/
|
2021-05-31 16:40:04 +01:00
|
|
|
public async expectations(nodeId: string | null): Promise<Expectation> {
|
2021-05-21 16:28:49 +01:00
|
|
|
return await this.payouts.expectations(nodeId);
|
|
|
|
}
|
2021-05-31 16:40:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetches total paystub of given node, period and satellite.
|
|
|
|
*
|
|
|
|
* @param satelliteId
|
|
|
|
* @param period
|
|
|
|
* @param nodeId - node id.
|
|
|
|
*
|
|
|
|
* @throws {@link BadRequestError}
|
|
|
|
* This exception is thrown if the input is not a valid.
|
|
|
|
*
|
|
|
|
* @throws {@link UnauthorizedError}
|
|
|
|
* Thrown if the auth cookie is missing or invalid.
|
|
|
|
*
|
|
|
|
* @throws {@link InternalError}
|
|
|
|
* Thrown if something goes wrong on server side.
|
|
|
|
*/
|
|
|
|
public async paystub(satelliteId: string | null, period: string | null, nodeId: string): Promise<Paystub> {
|
|
|
|
return await this.payouts.paystub(satelliteId, period, nodeId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetches held history of given node.
|
|
|
|
*
|
|
|
|
* @param nodeId - node id.
|
|
|
|
*
|
|
|
|
* @throws {@link BadRequestError}
|
|
|
|
* This exception is thrown if the input is not a valid.
|
|
|
|
*
|
|
|
|
* @throws {@link UnauthorizedError}
|
|
|
|
* Thrown if the auth cookie is missing or invalid.
|
|
|
|
*
|
|
|
|
* @throws {@link InternalError}
|
|
|
|
* Thrown if something goes wrong on server side.
|
|
|
|
*/
|
|
|
|
public async heldHistory(nodeId: string): Promise<HeldAmountSummary[]> {
|
|
|
|
return await this.payouts.heldHistory(nodeId);
|
|
|
|
}
|
2021-04-23 19:43:23 +01:00
|
|
|
}
|