Skip to content

Update ServiceFactory.deletefunction signature to take optional TPathParams #47

Description

@brandongregoryscott

Similiar to #46, the ServiceFactory.delete signature and implementation should be updated for greater flexibility.

It should look something like this:

    /**
     * Creates conventional Service Delete function for the supplied resource type
     * @param recordType
     * @param resourceEndpoint
     */
    delete<TPathParams extends any>(resourceEndpoint: string): DeleteService {
        return async (id: number, pathParams?: TPathParams) =>
            await _delete<TPathParams>(id, resourceEndpoint, pathParams);
    },

// ---------------------------------------------------------------------------------------------
// #region Private Functions
// ---------------------------------------------------------------------------------------------

const _delete = async function<TPathParams extends any>(
    id: number,
    resourceEndpoint: string,
    pathParams?: TPathParams
) {
    const url = _buildUrl(id, resourceEndpoint, pathParams);
    return await axios
        .delete(url)
        .then((r) => ServiceUtils.mapAxiosResponse(Boolean, r));
};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions