GetCustomer
Implements GetCustomer
Unified Method.
Source
import { defineApi } from "@vsf-enterprise/unified-api-sapcc";
import { getNormalizers } from "@vsf-enterprise/unified-api-sapcc/udl";
declare module "@vsf-enterprise/unified-api-sapcc" {
interface GetCustomerExtendedArgs {
/**
* Response configuration. List of fields returned in the response body.
*/
fields?: "BASIC" | "DEFAULT" | "FULL" | string | string[];
}
}
export const getCustomer = defineApi.getCustomer(async (context) => {
try {
const { data: user } = await context.api.getUser({});
const { normalizeCustomer } = getNormalizers(context);
return {
customer: normalizeCustomer(user),
};
} catch {
return {
customer: null,
};
}
});