-
Notifications
You must be signed in to change notification settings - Fork 0
BaseService
The BaseService class is an abstract service object designed to encapsulate common methods for service interactions within Salesforce Commerce Cloud (SFCC). It provides a foundational framework for creating and managing services, including handling service configurations, callbacks, error handling, and credentials. This class is intended to be extended by other service classes to create specific service implementations (e.g., REST, SOAP, SFTP).
Type: Object.<string, string>
Defines available service configurations by mapping aliases to service identifiers. The default key is typically used as the fallback configuration.
Type: string[]
An array of method names that can be overridden to customize service behavior. These methods include:
initServiceClientcreateRequestexecuteparseResponsefilterLogMessagegetRequestLogMessagegetResponseLogMessage
Type: string[]
An array of method names that can be overridden to configure mock service behavior. The methods include:
mockCallmockFull
Description: Extends the BaseService with custom service logic.
-
Parameters:
-
service(Object): An object containing custom service logic to be merged with the base service.
-
-
Returns:
-
Object: A new service object that includes both the base and custom logic.
-
Description: Initiates a service operation based on the provided alias or arguments. It creates a service instance, executes the service call, and handles the result based on success or failure.
-
Parameters:
-
aliasOrArgs(string | Object): The service alias to be used, or if not provided, the arguments. -
args(Object, optional): Additional arguments for the fetch operation.
-
-
Returns:
-
dw.svc.Result: The result of the service call, either success or error.
-
Description: Creates a service instance using the dw.svc.LocalServiceRegistry based on the provided service ID name.
-
Parameters:
-
alias(string, optional): The service alias for which the service instance is created. Defaults to 'default'. -
params(Object, optional): The arguments for the fetch operation.
-
-
Returns:
-
dw.svc.Service: The created service instance.
-
Description: Retrieves the configuration for a specific service alias.
-
Parameters:
-
alias(string): The service name for which the configuration is retrieved.
-
-
Returns:
-
string: The configuration for the specified service name.
-
-
Throws:
-
Error: If the alias is not defined inSERVICE_CONFIGURATIONS.
-
Description: Prepares and returns the service callback object based on the methods defined in SERVICE_CALLBACK_METHODS and SERVICE_CALLBACK_MOCK_METHODS.
-
Parameters:
-
params(Object, optional): The arguments for the fetch operation.
-
-
Returns:
-
dw.svc.ServiceCallback: The service callback configurations.
-
Description: Transforms an error result into a structured service result.
-
Parameters:
-
serviceResult(dw.svc.Result | Error): The original service result or an error. -
service(dw.svc.Service): The service instance.
-
-
Returns:
-
dw.svc.Result: The transformed service result with error details.
-
Description: Handles a successful service result.
-
Parameters:
-
result(dw.svc.Result): The successful service result. -
service(dw.svc.Service): The service instance.
-
-
Returns:
-
dw.svc.Result: The input result, typically unmodified.
-
Description: Retrieves the service credential for the service.
-
Parameters:
-
svc(dw.svc.Service): The service instance. -
params(Object): The service parameters.
-
-
Returns:
-
dw.svc.ServiceCredential: The service credential, typically used for authentication.
-