@@ -213,6 +213,7 @@ import { ImportAssetUseCase } from "@application/use-cases/import-asset.use-case
213213import { PauseAssetUseCase } from "@application/use-cases/pause-asset.use-case"
214214import { UnpauseAssetUseCase } from "@application/use-cases/unpause-asset.use-case"
215215import { Body , Get , HttpCode , HttpStatus , Param , Patch , Post , Query } from "@nestjs/common"
216+ import { ApiOperation , ApiResponse , ApiTags , ApiParam } from "@nestjs/swagger"
216217import { DistributionResponse } from "../distribution/distribution.response"
217218import { PageOptionsRequest } from "../page-options.request"
218219import { PageResponse } from "../page.response"
@@ -224,6 +225,7 @@ import { GetBasicAssetInformationResponse } from "./get-basic-asset-information.
224225import { ImportAssetRequest } from "./import-asset.request"
225226import { GetDistributionHolderCountUseCase } from "@application/use-cases/get-distribution-holder-count.use-case"
226227
228+ @ApiTags ( "Assets" )
227229@RestController ( "assets" )
228230export class AssetController {
229231 constructor (
@@ -240,36 +242,97 @@ export class AssetController {
240242 private readonly executePayoutUseCase : ExecutePayoutUseCase ,
241243 ) { }
242244
245+ @ApiOperation ( {
246+ summary : "Import an asset so the payments to its holders are managed by the Scheduler Payment Distribution Service" ,
247+ } )
248+ @ApiResponse ( { status : 500 , description : "Internal server error" } )
249+ @ApiResponse ( { status : 400 , description : "Bad Request" } )
250+ @ApiResponse ( { status : 401 , description : "Unauthorized" } )
251+ @ApiResponse ( { status : 404 , description : "Not Found" } )
252+ @ApiResponse ( { status : 201 , type : AssetResponse } )
243253 @Post ( "import" )
244254 async importAsset ( @Body ( ) request : ImportAssetRequest ) : Promise < AssetResponse > {
245255 const asset = await this . importAssetUseCase . execute ( request . hederaTokenAddress )
246256 return AssetResponse . fromAsset ( asset )
247257 }
248258
259+ @ApiOperation ( { summary : "Pause the Scheduler Payment Distribution Service for a certain asset." } )
260+ @ApiParam ( {
261+ name : "assetId" ,
262+ description : "The ID of the asset to pause." ,
263+ example : "0.0.123456" ,
264+ } )
265+ @ApiResponse ( { status : 500 , description : "Internal server error" } )
266+ @ApiResponse ( { status : 400 , description : "Bad Request" } )
267+ @ApiResponse ( { status : 401 , description : "Unauthorized" } )
268+ @ApiResponse ( { status : 404 , description : "Not Found" } )
269+ @ApiResponse ( {
270+ status : 200 ,
271+ description : "The asset LifeCycleCashFlow contract has been successfully paused." ,
272+ } )
249273 @Patch ( ":assetId/pause" )
250274 @HttpCode ( HttpStatus . OK )
251275 async pauseAsset ( @Param ( "assetId" ) assetId : string ) : Promise < void > {
252276 await this . pauseAssetUseCase . execute ( assetId )
253277 }
254278
279+ @ApiOperation ( { summary : "Unpause the Scheduler Payment Distribution Service for a certain asset." } )
280+ @ApiParam ( {
281+ name : "assetId" ,
282+ description : "The ID of the asset to unpause." ,
283+ example : "0.0.123456" ,
284+ } )
285+ @ApiResponse ( { status : 500 , description : "Internal server error" } )
286+ @ApiResponse ( { status : 400 , description : "Bad Request" } )
287+ @ApiResponse ( { status : 401 , description : "Unauthorized" } )
288+ @ApiResponse ( { status : 404 , description : "Not Found" } )
289+ @ApiResponse ( {
290+ status : 200 ,
291+ description : "The asset LifeCycleCashFlow contract has been successfully unpaused." ,
292+ } )
255293 @Patch ( ":assetId/unpause" )
256294 @HttpCode ( HttpStatus . OK )
257295 async unpauseAsset ( @Param ( "assetId" ) assetId : string ) : Promise < void > {
258296 await this . unpauseAssetUseCase . execute ( assetId )
259297 }
260298
299+ @ApiOperation ( { summary : "Get the assets list managed by the Scheduler Payment Distribution Service." } )
300+ @ApiResponse ( { status : 500 , description : "Internal server error" } )
301+ @ApiResponse ( { status : 400 , description : "Bad Request" } )
302+ @ApiResponse ( { status : 401 , description : "Unauthorized" } )
303+ @ApiResponse ( { status : 404 , description : "Not Found" } )
304+ @ApiResponse ( { status : 200 , type : PageResponse < AssetResponse > } )
261305 @Get ( )
262306 async getAssets ( @Query ( ) pageOptions : PageOptionsRequest ) : Promise < PageResponse < AssetResponse > > {
263307 const result = await this . getAssetsUseCase . execute ( pageOptions . toPageOptions ( ) )
264308 return PageResponse . fromPage ( result , AssetResponse . fromAsset )
265309 }
266310
311+ @ApiOperation ( { summary : "Get a certain asset managed by the Scheduler Payment Distribution Service." } )
312+ @ApiParam ( {
313+ name : "assetId" ,
314+ description : "The ID of the asset to unpause." ,
315+ example : "0.0.123456" ,
316+ } )
317+ @ApiResponse ( { status : 500 , description : "Internal server error" } )
318+ @ApiResponse ( { status : 400 , description : "Bad Request" } )
319+ @ApiResponse ( { status : 401 , description : "Unauthorized" } )
320+ @ApiResponse ( { status : 404 , description : "Not Found" } )
321+ @ApiResponse ( { status : 200 , type : AssetResponse } )
267322 @Get ( ":assetId" )
268323 async getAsset ( @Param ( "assetId" ) assetId : string ) : Promise < AssetResponse > {
269324 const asset = await this . getAssetUseCase . execute ( assetId )
270325 return AssetResponse . fromAsset ( asset )
271326 }
272327
328+ @ApiOperation ( {
329+ summary : "Get the basic information of a certain asset managed by the Scheduler Payment Distribution Service." ,
330+ } )
331+ @ApiResponse ( { status : 500 , description : "Internal server error" } )
332+ @ApiResponse ( { status : 400 , description : "Bad Request" } )
333+ @ApiResponse ( { status : 401 , description : "Unauthorized" } )
334+ @ApiResponse ( { status : 404 , description : "Not Found" } )
335+ @ApiResponse ( { status : 200 , type : GetBasicAssetInformationResponse } )
273336 @Get ( ":hederaTokenAddress/metadata" )
274337 async getBasicAssetInformation (
275338 @Param ( ) request : GetBasicAssetInformationRequest ,
@@ -284,6 +347,19 @@ export class AssetController {
284347 )
285348 }
286349
350+ @ApiOperation ( {
351+ summary : "Get distributions information of a certain asset managed by the Scheduler Payment Distribution Service." ,
352+ } )
353+ @ApiParam ( {
354+ name : "assetId" ,
355+ description : "The ID of the asset to get its distributions information." ,
356+ example : "0.0.123456" ,
357+ } )
358+ @ApiResponse ( { status : 500 , description : "Internal server error" } )
359+ @ApiResponse ( { status : 400 , description : "Bad Request" } )
360+ @ApiResponse ( { status : 401 , description : "Unauthorized" } )
361+ @ApiResponse ( { status : 404 , description : "Not Found" } )
362+ @ApiResponse ( { status : 200 , type : PageResponse < DistributionResponse > } )
287363 @Get ( ":assetId/distributions" )
288364 async getAssetDistributions (
289365 @Param ( "assetId" ) assetId : string ,
@@ -299,6 +375,20 @@ export class AssetController {
299375 return distributions
300376 }
301377
378+ @ApiOperation ( { summary : "Create a batch payout." } )
379+ @ApiParam ( {
380+ name : "assetId" ,
381+ description : "The ID of the asset to create a batch payout for" ,
382+ example : "0.0.123456" ,
383+ } )
384+ @ApiResponse ( { status : 500 , description : "Internal server error" } )
385+ @ApiResponse ( { status : 400 , description : "Bad Request" } )
386+ @ApiResponse ( { status : 401 , description : "Unauthorized" } )
387+ @ApiResponse ( { status : 404 , description : "Not Found" } )
388+ @ApiResponse ( {
389+ status : 201 ,
390+ description : "The asset payout has been successfully created." ,
391+ } )
302392 @Post ( ":assetId/distributions/payout" )
303393 @HttpCode ( HttpStatus . CREATED )
304394 async createPayout ( @Param ( "assetId" ) assetId : string , @Body ( ) request : CreatePayoutRequest ) : Promise < void > {
@@ -313,13 +403,35 @@ export class AssetController {
313403 } )
314404 }
315405
406+ @ApiOperation ( { summary : "Enable the asset synchronization." } )
407+ @ApiParam ( {
408+ name : "assetId" ,
409+ description : "The ID of the asset to enable the sync." ,
410+ example : "0.0.123456" ,
411+ } )
412+ @ApiResponse ( { status : 500 , description : "Internal server error" } )
413+ @ApiResponse ( { status : 400 , description : "Bad Request" } )
414+ @ApiResponse ( { status : 401 , description : "Unauthorized" } )
415+ @ApiResponse ( { status : 404 , description : "Not Found" } )
416+ @ApiResponse ( { status : 200 , type : AssetResponse } )
316417 @Patch ( ":assetId/enable-sync" )
317418 @HttpCode ( HttpStatus . OK )
318419 async enableAssetSync ( @Param ( "assetId" ) assetId : string ) : Promise < AssetResponse > {
319420 const asset = await this . enableAssetSyncUseCase . execute ( assetId )
320421 return AssetResponse . fromAsset ( asset )
321422 }
322423
424+ @ApiOperation ( { summary : "Disable the asset synchronization." } )
425+ @ApiParam ( {
426+ name : "assetId" ,
427+ description : "The ID of the asset to disable the sync." ,
428+ example : "0.0.123456" ,
429+ } )
430+ @ApiResponse ( { status : 500 , description : "Internal server error" } )
431+ @ApiResponse ( { status : 400 , description : "Bad Request" } )
432+ @ApiResponse ( { status : 401 , description : "Unauthorized" } )
433+ @ApiResponse ( { status : 404 , description : "Not Found" } )
434+ @ApiResponse ( { status : 200 , type : AssetResponse } )
323435 @Patch ( ":assetId/disable-sync" )
324436 @HttpCode ( HttpStatus . OK )
325437 async disableAssetSync ( @Param ( "assetId" ) assetId : string ) : Promise < AssetResponse > {
0 commit comments