@@ -24,6 +24,7 @@ import { DocumentStatusRequestEnum } from '../models/DocumentStatusRequestEnum';
2424import { DocumentStatusResponse } from '../models/DocumentStatusResponse' ;
2525import { DocumentTransferAllOwnershipRequest } from '../models/DocumentTransferAllOwnershipRequest' ;
2626import { DocumentTransferOwnershipRequest } from '../models/DocumentTransferOwnershipRequest' ;
27+ import { DocumentUpdateRequest } from '../models/DocumentUpdateRequest' ;
2728import { LinkedObjectCreateRequest } from '../models/LinkedObjectCreateRequest' ;
2829import { LinkedObjectCreateResponse } from '../models/LinkedObjectCreateResponse' ;
2930import { LinkedObjectListResponse } from '../models/LinkedObjectListResponse' ;
@@ -974,6 +975,66 @@ export class DocumentsApiRequestFactory extends BaseAPIRequestFactory {
974975 return requestContext ;
975976 }
976977
978+ /**
979+ * Update Document only in the draft status
980+ * @param id Document ID
981+ * @param documentUpdateRequest
982+ */
983+ public async updateDocument ( id : string , documentUpdateRequest : DocumentUpdateRequest , _options ?: Configuration ) : Promise < RequestContext > {
984+ let _config = _options || this . configuration ;
985+
986+ // verify required parameter 'id' is not null or undefined
987+ if ( id === null || id === undefined ) {
988+ throw new RequiredError ( "DocumentsApi" , "updateDocument" , "id" ) ;
989+ }
990+
991+
992+ // verify required parameter 'documentUpdateRequest' is not null or undefined
993+ if ( documentUpdateRequest === null || documentUpdateRequest === undefined ) {
994+ throw new RequiredError ( "DocumentsApi" , "updateDocument" , "documentUpdateRequest" ) ;
995+ }
996+
997+
998+ // Path Params
999+ const localVarPath = '/public/v1/documents/{id}'
1000+ . replace ( '{' + 'id' + '}' , encodeURIComponent ( String ( id ) ) ) ;
1001+
1002+ // Make Request Context
1003+ const requestContext = _config . baseServer . makeRequestContext ( localVarPath , HttpMethod . PATCH ) ;
1004+ requestContext . setHeaderParam ( "Accept" , "application/json, */*;q=0.8" )
1005+
1006+
1007+ // Body Params
1008+ const contentType = ObjectSerializer . getPreferredMediaType ( [
1009+ "application/json"
1010+ ] ) ;
1011+ requestContext . setHeaderParam ( "Content-Type" , contentType ) ;
1012+ const serializedBody = ObjectSerializer . stringify (
1013+ ObjectSerializer . serialize ( documentUpdateRequest , "DocumentUpdateRequest" , "" ) ,
1014+ contentType
1015+ ) ;
1016+ requestContext . setBody ( serializedBody ) ;
1017+
1018+ let authMethod : SecurityAuthentication | undefined ;
1019+ // Apply auth methods
1020+ authMethod = _config . authMethods [ "apiKey" ]
1021+ if ( authMethod ?. applySecurityAuthentication ) {
1022+ await authMethod ?. applySecurityAuthentication ( requestContext ) ;
1023+ }
1024+ // Apply auth methods
1025+ authMethod = _config . authMethods [ "oauth2" ]
1026+ if ( authMethod ?. applySecurityAuthentication ) {
1027+ await authMethod ?. applySecurityAuthentication ( requestContext ) ;
1028+ }
1029+
1030+ const defaultAuth : SecurityAuthentication | undefined = _options ?. authMethods ?. default || this . configuration ?. authMethods ?. default
1031+ if ( defaultAuth ?. applySecurityAuthentication ) {
1032+ await defaultAuth ?. applySecurityAuthentication ( requestContext ) ;
1033+ }
1034+
1035+ return requestContext ;
1036+ }
1037+
9771038}
9781039
9791040export class DocumentsApiResponseProcessor {
@@ -1856,4 +1917,64 @@ export class DocumentsApiResponseProcessor {
18561917 throw new ApiException < string | Buffer | undefined > ( response . httpStatusCode , "Unknown API Status Code!" , await response . getBodyAsAny ( ) , response . headers ) ;
18571918 }
18581919
1920+ /**
1921+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
1922+ * to the expected objects
1923+ *
1924+ * @params response Response returned by the server for a request to updateDocument
1925+ * @throws ApiException if the response code was not in [200, 299]
1926+ */
1927+ public async updateDocument ( response : ResponseContext ) : Promise < void > {
1928+ const contentType = ObjectSerializer . normalizeMediaType ( response . headers [ "content-type" ] ) ;
1929+ if ( isCodeInRange ( "204" , response . httpStatusCode ) ) {
1930+ return ;
1931+ }
1932+ if ( isCodeInRange ( "400" , response . httpStatusCode ) ) {
1933+ const body : any = ObjectSerializer . deserialize (
1934+ ObjectSerializer . parse ( await response . body . text ( ) , contentType ) ,
1935+ "any" , ""
1936+ ) as any ;
1937+ throw new ApiException < any > ( 400 , "Bad Request" , body , response . headers ) ;
1938+ }
1939+ if ( isCodeInRange ( "401" , response . httpStatusCode ) ) {
1940+ const body : any = ObjectSerializer . deserialize (
1941+ ObjectSerializer . parse ( await response . body . text ( ) , contentType ) ,
1942+ "any" , ""
1943+ ) as any ;
1944+ throw new ApiException < any > ( 401 , "Authentication error" , body , response . headers ) ;
1945+ }
1946+ if ( isCodeInRange ( "403" , response . httpStatusCode ) ) {
1947+ const body : any = ObjectSerializer . deserialize (
1948+ ObjectSerializer . parse ( await response . body . text ( ) , contentType ) ,
1949+ "any" , ""
1950+ ) as any ;
1951+ throw new ApiException < any > ( 403 , "Permission error" , body , response . headers ) ;
1952+ }
1953+ if ( isCodeInRange ( "404" , response . httpStatusCode ) ) {
1954+ const body : any = ObjectSerializer . deserialize (
1955+ ObjectSerializer . parse ( await response . body . text ( ) , contentType ) ,
1956+ "any" , ""
1957+ ) as any ;
1958+ throw new ApiException < any > ( 404 , "Not found" , body , response . headers ) ;
1959+ }
1960+ if ( isCodeInRange ( "429" , response . httpStatusCode ) ) {
1961+ const body : any = ObjectSerializer . deserialize (
1962+ ObjectSerializer . parse ( await response . body . text ( ) , contentType ) ,
1963+ "any" , ""
1964+ ) as any ;
1965+ throw new ApiException < any > ( 429 , "Too Many Requests" , body , response . headers ) ;
1966+ }
1967+
1968+ // Work around for missing responses in specification, e.g. for petstore.yaml
1969+ if ( response . httpStatusCode >= 200 && response . httpStatusCode <= 299 ) {
1970+ const body : void = ObjectSerializer . deserialize (
1971+ ObjectSerializer . parse ( await response . body . text ( ) , contentType ) ,
1972+ "void" , ""
1973+ ) as void ;
1974+ return body ;
1975+ }
1976+
1977+ throw new ApiException < string | Buffer | undefined > ( response . httpStatusCode , "Unknown API Status Code!" , await response . getBodyAsAny ( ) , response . headers ) ;
1978+ }
1979+
18591980}
0 commit comments