Skip to content

WebDavService

Dmytro Katashev edited this page Aug 12, 2024 · 1 revision

WebDavService API Reference

Overview

The WebDavService class extends the BaseService class, providing specialized functionality for interacting with WebDAV services in Salesforce Commerce Cloud (SFCC). It handles the creation of WebDAV requests, execution of operations, and parsing of responses, making it easier to interact with remote file systems over the WebDAV protocol.

Inherits from: BaseService


Public Methods

fetch(params: WebdavParams)

Description: Executes a WebDAV service call based on the provided parameters. It utilizes the createRequest, execute, and parseResponse methods to manage the client connection and handle the specified operation.

  • Parameters:
    • params (WebdavParams): The parameters for creating and executing the WebDAV service request.
  • Returns:
    • dw.svc.Result: The result of the service call, either success or error.

createRequest(svc: WebDAVService, params: WebdavParams)

Description: Creates a request for the WebDAV service based on the provided parameters.

  • Parameters:
    • svc (WebDAVService): The WebDAV service instance.
    • params (WebdavParams): The parameters for creating the request.
  • Returns:
    • WebdavParams: The input parameters.

execute(svc: WebDAVService, params: WebdavParams)

Description: Executes the specified WebDAV operation. Supports both single and multiple operations via callbacks.

  • Parameters:
    • svc (WebDAVService): The WebDAV service instance.
    • params (WebdavParams): The parameters for executing the operations.
  • Returns:
    • *: The result of the executed operation.
  • Throws:
    • Error: If the WebDAV call fails.

parseResponse(svc: WebDAVService, response: any)

Description: Parses the response from the WebDAV service and ensures the client connection is properly closed.

  • Parameters:
    • svc (WebDAVService): The WebDAV service instance.
    • response (any): The response to parse.
  • Returns:
    • *: The parsed response content.

Protected/Internal Methods

_buildCompleteUrl(url: string, params: { pathPatterns: Object.<string, string>, queryParams: Object.<string, string> })

Description: Completes a URL by replacing path patterns and appending query parameters.

  • Parameters:
    • url (string): The base URL.
    • params (Object): The parameters containing path patterns and query parameters.
    • params.pathPatterns (Object.<string, string>): Patterns to replace in the URL.
    • params.queryParams (Object.<string, string>): Query parameters to append to the URL.
  • Returns:
    • string: The complete URL.

Types and Callbacks

WebDAVService

Represents a WebDAV service instance, including a dw.net.WebDAVClient for handling requests.

  • Type: dw.svc.Service & { client: dw.net.WebDAVClient }

WebdavParams

Represents parameters for the WebDAV service.

  • Type: Object
    • pathPatterns (Object.<string,string>): Patterns to replace in the URL.
    • queryParams (Object.<string,string>): Query parameters to include in the request.
    • headers (Object.<string,string>): Headers to include in the request.
    • operation ('copy' | 'del' | 'get' | 'getBinary' | 'mkcol' | 'move' | 'options' | 'propfind' | 'put'): The WebDAV operation to be executed.
    • args (*[]): Arguments for the specified operation.
    • onExecute (function): Callback function for executing multiple operations.

onExecute

Callback function for executing WebDAV operations.

  • Type: function
    • Parameters:
      • svc (WebDAVService): The WebDAV service instance.
    • Returns:
      • *: The result of the executed operations.

onCreateRequest

Callback function for customizing the WebDAV request.

  • Type: function
    • Parameters:
      • params (WebdavParams): The WebDAV parameters.
      • svc (WebDAVService): The WebDAV service instance.
      • serviceCredential (dw.svc.ServiceCredential): The service credential.
    • Returns:
      • void: No return value.

Clone this wiki locally