Skip to content

Commit

Permalink
docs: generate report
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ committed Jun 11, 2023
1 parent 1e7f0a3 commit b29de5c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Create Glossary](#create-glossary)
- [Pre-Translate project](#pre-translate-project)
- [Download translations](#download-translations)
- [Generate report](#generate-report)

---

Expand Down Expand Up @@ -197,3 +198,36 @@ async function downloadTranslations(projectId: number): Promise<string> {
downloadTranslations(123);

```

## Generate report

```typescript
import crowdin from '@crowdin/crowdin-api-client';

const { reportsApi } = new crowdin({
token: 'token',
organization: 'org'
});

async function downloadTranslations(projectId: number): Promise<string> {
const result = await reportsApi.generateReport(projectId, {
name: 'costs-estimation',
schema: {
languageId: 'uk',
},
});

let status = result.data.status;
while (status !== 'finished') {
const progress = await reportsApi.checkReportStatus(projectId, result.data.identifier);
status = progress.data.status;
}

const report = await reportsApi.downloadReport(projectId, result.data.identifier);

return report.data.url;
}

downloadTranslations(123);

```
2 changes: 1 addition & 1 deletion src/reports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export namespace ReportsModel {
}

export interface GenerateReportRequest {
name: string;
name: 'costs-estimation' | 'translation-costs' | 'top-members' | 'contribution-raw-data';
schema:
| CostEstimateSchema
| CostEstimateFuzzyModeSchema
Expand Down
2 changes: 1 addition & 1 deletion tests/reports/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Reports API', () => {
const projectId = 2;
const groupId = 23;
const reportId = '123';
const reportName = 'testReport';
const reportName = 'costs-estimation';
const downloadLink = 'test.com';
const schema: ReportsModel.TopMembersSchema = {
unit: 'chars',
Expand Down

0 comments on commit b29de5c

Please sign in to comment.