Skip to content

Commit

Permalink
update typings
Browse files Browse the repository at this point in the history
  • Loading branch information
parky128 committed Feb 15, 2019
1 parent b1737c6 commit 910c6be
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
47 changes: 24 additions & 23 deletions src/cargo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,40 @@
import { ALClient, APIRequestParams } from '@al/client';

export interface TableauReportDefinition {
site_id: string;
workbook_id: string;
view_id: string;
saved_view_id: string;
site_id?: string;
workbook_id?: string;
view_id?: string;
saved_view_id?: string;
}

export interface ReportTimeRange {
days: number;
hours: number;
minutes: number;
export interface CargoReportTimeRange {
days?: number;
hours?: number;
minutes?: number;
}

export interface SearchReportDefinition {
saved_query_id: string;
timerange: ReportTimeRange;
timerange?: CargoReportTimeRange;
}

export interface CreateReportRequest {
name: string;
type: 'search' | 'tableau';
type: string;
definition: SearchReportDefinition | TableauReportDefinition;
schedule: string;
is_active: boolean;
per_accounts_id: string[];
schedule?: string;
is_active?: boolean;
per_accounts_id?: string[];
}

export interface CreateReportResponse {
id: string;
}

export interface ReportScheduleRequest {
report_id: string;
scheduled_time: string;
sub_results: {
scheduled_time?: string;
sub_results?: {
account_id: string;
}[];
}
Expand Down Expand Up @@ -114,7 +118,7 @@ class CargoClient {
path: '/report',
data: reportRequest,
});
return result;
return result as CreateReportResponse;
}
/**
* Get report for given account_id and report_id
Expand Down Expand Up @@ -153,16 +157,13 @@ class CargoClient {
/**
* Get list of reports for given account_id
*/
async listReports(accountId: string, queryParams?: any) {
const apiRequestParams: APIRequestParams = {
async listReports(accountId: string, queryParams: {report_type?: string} = {}) {
const reports = await this.alClient.fetch({
service_name: this.serviceName,
account_id: accountId,
path: '/report',
};
if (queryParams) {
apiRequestParams.params = queryParams;
}
const reports = await this.alClient.fetch(apiRequestParams);
params: queryParams,
});
return reports as CargoReportListResponse;
}
/**
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
export {
cargoClient as CargoClient,
CargoReport,
CreateReportRequest,
CreateReportResponse,
SearchReportDefinition,
CargoReportResponse,
CargoReportTimeRange,
CargoReportListResponse,
CargoScheduledReportResponse,
CargoScheduledReportListResponse,
Expand Down

0 comments on commit 910c6be

Please sign in to comment.