-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
The internal project that most of this package was based off of has since evolved - we've seen the need for query params in an update service call. The signature & implementation should be updated to be more flexible for consumers. It should look something like this:
/**
* Creates conventional Service Update function for the supplied resource type
* @param recordType
* @param resourceEndpoint
*/
update<
TRecord extends any,
TPathParams extends any,
TQueryParams = undefined
>(
recordType: { new (): TRecord },
resourceEndpoint: string
): UpdateService<TRecord, TPathParams, TQueryParams> {
return async (
record: TRecord,
pathParams?: TPathParams,
queryParams?: TQueryParams
) =>
await _update<TRecord, TPathParams, TQueryParams>(
recordType,
record,
resourceEndpoint,
pathParams,
queryParams
);
},
// ---------------------------------------------------------------------------------------------
// #region Private Functions
// ---------------------------------------------------------------------------------------------
const _update = async function<
TRecord extends any,
TPathParams extends any,
TQueryParams extends any = any
>(
recordType: { new (): TRecord },
record: TRecord,
resourceEndpoint: string,
pathParams?: TPathParams,
queryParams?: TQueryParams
) {
const url = _buildUrl(record.id, resourceEndpoint, pathParams, queryParams);
return await axios
.put(url, record.toJS())
.then((r) => ServiceUtils.mapAxiosResponse(recordType, r));
};Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers