Skip to content

Commit

Permalink
feat: update types and documentation for usage statistics [SDK-23]
Browse files Browse the repository at this point in the history
  • Loading branch information
klausborges committed Mar 24, 2022
1 parent 5849682 commit 31eef20
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
18 changes: 17 additions & 1 deletion src/modules/Account/Profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,25 @@ class Profile extends TagoIOModule<GenericModuleParams> {
}

/**
* List all the usage statistics of your profile
* List all the usage statistics of a profile.
*
* Usage statistics are cumulative: if a service was not used in a time period,
* the statistics for that time period will not be in the object.
*
* @param profileID Profile identification
* @param dateObj Object with date and their timezone
*
* @returns Array of cumulative usage statistics.
*
* @example
*
* ```json
* [
* { "time": "2022-01-01T00:00:00.000Z", "input": 5 },
* { "time": "2022-01-01T00:00:00.000Z", "input": 5, "output": 10 },
* { "time": "2022-01-01T00:00:00.000Z", "input": 10, "output": 15 },
* ]
* ```
*/
public async usageStatisticList(
profileID: GenericID,
Expand Down
20 changes: 11 additions & 9 deletions src/modules/Account/profile.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GenericID } from "../../common/common.types";
import { BillingService } from "./billing.types";

interface ProfileListInfo {
id: GenericID;
Expand Down Expand Up @@ -66,16 +67,17 @@ interface ProfileSummary {
};
}

interface UsageStatistic {
input: number;
input_peak: number;
output: number;
analysis: number;
data_records: number;
/**
* Type for a single usage statistic with timestamp.
*
* Not all of the services will be present for every statistic, only if for the usage period the service was used.
*/
type UsageStatistic = Partial<Record<BillingService, number>> & {
/**
* Timestamp for the usage statistic.
*/
time: Date;
sms: number;
email: number;
}
};

interface AuditLog {
events?: {
Expand Down

0 comments on commit 31eef20

Please sign in to comment.