1-
1+
22using System ;
33using System . Collections . Generic ;
44using System . Linq ;
@@ -467,5 +467,76 @@ public async Task<DownloadLink> DownloadReviewedSourceFiles(long projectId, long
467467 }
468468
469469 #endregion
470+
471+ #region File References
472+
473+ /// <summary>
474+ /// List asset references. Documentation:
475+ /// <a href="https://support.crowdin.com/api/v2/#operation/api.projects.files.references.getMany">Crowdin API</a>
476+ /// <a href="https://support.crowdin.com/enterprise/api/#operation/api.projects.files.references.getMany">Crowdin Enterprise API</a>
477+ /// </summary>
478+ [ PublicAPI ]
479+ public async Task < ResponseList < AssetReference > > ListAssetReferences ( long projectId , long fileId , int limit = 25 , int offset = 0 )
480+ {
481+ string url = FormUrl_FileReferences ( projectId , fileId ) ;
482+ IDictionary < string , string > queryParams = Utils . CreateQueryParamsFromPaging ( limit , offset ) ;
483+ CrowdinApiResult result = await _apiClient . SendGetRequest ( url , queryParams ) ;
484+ return _jsonParser . ParseResponseList < AssetReference > ( result . JsonObject ) ;
485+ }
486+
487+ /// <summary>
488+ /// Add asset reference. Documentation:
489+ /// <a href="https://support.crowdin.com/api/v2/#operation/api.projects.files.references.post">Crowdin API</a>
490+ /// <a href="https://support.crowdin.com/enterprise/api/#operation/api.projects.files.references.post">Crowdin Enterprise API</a>
491+ /// </summary>
492+ [ PublicAPI ]
493+ public async Task < AssetReference > AddAssetReference ( long projectId , long fileId , AddAssetReferenceRequest request )
494+ {
495+ string url = FormUrl_FileReferences ( projectId , fileId ) ;
496+ CrowdinApiResult result = await _apiClient . SendPostRequest ( url , request ) ;
497+ return _jsonParser . ParseResponseObject < AssetReference > ( result . JsonObject ) ;
498+ }
499+
500+ /// <summary>
501+ /// Get asset reference. Documentation:
502+ /// <a href="https://support.crowdin.com/api/v2/#operation/api.projects.files.references.get">Crowdin API</a>
503+ /// <a href="https://support.crowdin.com/enterprise/api/#operation/api.projects.files.references.get">Crowdin Enterprise API</a>
504+ /// </summary>
505+ [ PublicAPI ]
506+ public async Task < AssetReference > GetAssetReference ( long projectId , long fileId , long referenceId )
507+ {
508+ string url = FormUrl_FileReferences_ReferenceId ( projectId , fileId , referenceId ) ;
509+ CrowdinApiResult result = await _apiClient . SendGetRequest ( url ) ;
510+ return _jsonParser . ParseResponseObject < AssetReference > ( result . JsonObject ) ;
511+ }
512+
513+ /// <summary>
514+ /// Delete asset reference. Documentation:
515+ /// <a href="https://support.crowdin.com/api/v2/#operation/api.projects.files.references.delete">Crowdin API</a>
516+ /// <a href="https://support.crowdin.com/enterprise/api/#operation/api.projects.files.references.delete">Crowdin Enterprise API</a>
517+ /// </summary>
518+ [ PublicAPI ]
519+ public async Task DeleteAssetReference ( long projectId , long fileId , long referenceId )
520+ {
521+ string url = FormUrl_FileReferences_ReferenceId ( projectId , fileId , referenceId ) ;
522+ HttpStatusCode statusCode = await _apiClient . SendDeleteRequest ( url ) ;
523+ Utils . ThrowIfStatusNot204 ( statusCode , $ "File reference { referenceId } removal failed") ;
524+ }
525+
526+ #region Helper methods
527+
528+ private static string FormUrl_FileReferences ( long projectId , long fileId )
529+ {
530+ return $ "/projects/{ projectId } /files/{ fileId } /references";
531+ }
532+
533+ private static string FormUrl_FileReferences_ReferenceId ( long projectId , long fileId , long referenceId )
534+ {
535+ return $ "/projects/{ projectId } /files/{ fileId } /references/{ referenceId } ";
536+ }
537+
538+ #endregion
539+
540+ #endregion
470541 }
471542}
0 commit comments