It seems that you've misinterpretted what an enum is. Think of an enum as a collection of potential values (constants) for a given property.
As an example, in TypeScript, this would be represented as:
enum VehicleType {
motorcyle = 'motorcycle',
car = 'car',
truck = 'truck',
van = 'van'
}
class Vehicle {
...
type: VehicleType;
...
}
To appropriate the above to your response, you would want to rethink the approach. Ideally you would want to create an enum for every property that requires it and create a type for the request body. Then you would want to apply that type to the constant in your controller and use the enums you created to assign the values to the properties. That might look something like this:
// Potentially a class, but I've used an interface for this example
interface RequestBody {
clientId: number;
orderingId: number;
receivedSignatureFlag: ReceivedSignature; // Created a seperate enum for these 2 properties
saturdayDeliveryFlag: SaturdayDelivery;
deliveryMethodOptionCode: string; // Could potentially also be an enum
orderItemsList: any[]; // Using a generic type here to save time
}
enum ReceivedSignature {
N = 'N',
Y = 'Y',
DIGITAL = 'DIGITAL'
}
enum SaturdayDelivery {
N = 'N',
Y = 'Y',
}
// This is now typed
const requestBody: RequestBody = {
clientId: clientId,
orderingId: 113875599,
receivedSignatureFlag: ReceivedSignature.N,
saturdayDeliveryFlag: SaturdayDelivery.N,
deliveryMethodOptionCode: 'USPS',
orderItemsList: [
{
itemCode: 'A123',
transferCode: 'MAIL',
specialHandling: 'N',
deliveryExternalFlag: 'Y',
orderQuantityAmount: 1,
}
]
};
It should be noted though that if the flags are binary in nature (either being 'N' or 'Y') you should probably stick with primitive boolean type. Note that I've added in a DIGITAL constant to the ReceivedSignature enum, making the enum necessary for that property. However it could be argued that the enum is unnecessary for the saturdayDeliveryFlag property.