Skip to content

Commit

Permalink
Stash: useCase docs WIP. Added initial docs for GetAllDatasetPreviews…
Browse files Browse the repository at this point in the history
… use case
  • Loading branch information
GPortas committed Jan 24, 2024
1 parent e79e4d1 commit 0db5faa
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/useCases.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,35 @@ The different use cases currently available in the package are classified below,

## Datasets

### Read operations

#### [GetAllDatasetPreviews](../src/datasets/domain/useCases/GetAllDatasetPreviews.ts)

Returns an instance of [DatasetPreviewSubset](../src/datasets/domain/models/DatasetPreviewSubset.ts) that contains information for each dataset that the calling user can access in the installation.

##### Example call:

````typescript
import { getAllDatasetPreviews } from '@iqss/dataverse-client-javascript'

/* ... */

const limit = 10;
const offset = 20;

getAllDatasetPreviews
.execute(limit, offset)
.then((subset: DatasetPreviewSubset) => {
/* ... */
});

/* ... */
````

Note that `limit` and `offset` are optional parameters for pagination.

#### [GetDataset](../src/datasets/domain/useCases/GetDataset.ts)

TODO

## Files
Expand Down
7 changes: 7 additions & 0 deletions src/datasets/domain/useCases/GetAllDatasetPreviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ export class GetAllDatasetPreviews implements UseCase<DatasetPreviewSubset> {
this.datasetsRepository = datasetsRepository;
}

/**
* Returns an instance of DatasetPreviewSubset that contains information for each dataset that the calling user can access in the installation.
*
* @param {number} [limit] - Limit for pagination (optional).
* @param {number} [offset] - Offset for pagination (optional).
* @returns {Promise<DatasetPreviewSubset>}
*/
async execute(limit?: number, offset?: number): Promise<DatasetPreviewSubset> {
return await this.datasetsRepository.getAllDatasetPreviews(limit, offset);
}
Expand Down

0 comments on commit 0db5faa

Please sign in to comment.