d-velop / dvelop-sdk-node

Official SDK to build Apps for d.velop cloud
Apache License 2.0
10 stars 14 forks source link

updateDmsObject accepts categoryId but category is not updated #195

Closed alexandrudanpop closed 2 months ago

alexandrudanpop commented 2 months ago

When using the SDK updateDmsObject function, I noticed that the category is not updated. Could this be checked? Thanks for considering my request.

https://github.com/d-velop/dvelop-sdk-node/blob/main/packages/dms/src/dms-objects/update-dms-object/update-dms-object.ts#L19

LenKlose commented 2 months ago

Hi @alexandrudanpop,

thanks for your feedback! Could you please include the whole request (including the payload). Best case you could supply the request as curl which is not working as intended.

alexandrudanpop commented 2 months ago

Thanks for answering @LenKlose. This is the call I make using the SDK. The call works updating the properties but not the category. Looking at the SDK it looks like the param categoryId is not used.

https://github.com/d-velop/dvelop-sdk-node/blob/main/packages/dms/src/dms-objects/update-dms-object/update-dms-object.ts#L19

      import { DmsObject, updateDmsObject } from "@dvelop-sdk/dms";

      await updateDmsObject(
        {
          systemBaseUri,
          authSessionId,
        },
        {
          repositoryId: dmsObject.repositoryId,
          sourceId: dmsObject.sourceId,
          dmsObjectId: dmsObject.dmsObjectId,
          alterationText: `...`,
          categoryId: destinationCategoryId,
          properties: newProperties,
        }
      );

I created my own HTTP call for it but it would be nice if it worked in the SDK.

export const updateDmsObjectAndCategory = async (
  systemBaseUri: string,
  authSessionId: string,
  destinationCategoryId: string,
  destinationCategory: string,
  dmsObject: DmsObject,
  newProperties: { key: string; values: string[] }[]
) => {
  return axios.put(
    `${systemBaseUri}/dms/r/${dmsObject.repositoryId}/o2m/${dmsObject.dmsObjectId}`,
    {
      alterationText: `...`,
      sourceId: dmsObject.sourceId,
      sourceCategory: destinationCategoryId,
      sourceProperties: {
        properties: newProperties,
      },
    },
    {
      headers: {
        Authorization: `Bearer ${authSessionId}`,
      },
      timeout: REQUEST_TIMEOUT,
      timeoutErrorMessage: "...",
    }
  );
};
LenKlose commented 2 months ago

Hi @alexandrudanpop ,

the problem should be fixed in @dvelop-sdk/dms@1.5.5

Could you please verify, it works for your scenario now, by testing it after running npm i @dvleop-sdk/dms@next. We will then shortly tag the fixed version as latest

alexandrudanpop commented 2 months ago

From my brief testing this works, thanks for the prompt fix @LenKlose !

LenKlose commented 2 months ago

197 has been merched. thanks for your contribution!