Webigail
    Preparing search index...

    Class ZRestfulService<T>

    A generic implementation of a restful service that assumes all verbs are implemented.

    This can be used to invoke a service that is only partially implemented. If your service, for example, is read only, then create, upsert, update, and delete should all return not found or forbidden errors.

    Type Parameters

    • T

      The type of resource being retrieved or mutated.

    Implements

    Index

    Constructors

    • Initializes a new instance of this object.

      Type Parameters

      • T

        The type of resource being retrieved or mutated.

      Parameters

      • _http: IZHttpService

        The http service to use when invoking the RESTful service.

      • _endpointUrl: string

        The root url of the endpoint to hit. This can include params to send them with every request, but standard params of page, size, search, filter, and sort will be overridden depending on which method is being invoked.

      • _request: IZHttpRequest<any> = ...

        The base request to use when constructing requests in the http service.

      Returns ZRestfulService<T>

    Methods

    • Retrieves the total count of data items before pagination.

      Parameters

      • req: IZDataRequest

        The data request being made. The page and size fields are ignored in this instance.

      Returns Promise<number>

      The total number of items across pages that the request data set will represent.

    • Partially updates an existing resource entity.

      This uses the PATCH verb.

      Parameters

      • identification: string | number

        The identification of the resource to update.

      • fields: Partial<T>

        The partial fields to update.

      Returns Promise<T>

      The resource that was updated.

    • Creates a new entity or updates an existing entity.

      This is determined by the body parameters on whether or not an entity already exists.

      This uses the PUT verb.

      Parameters

      • body: T

        The post body that represents the resource to create or update.

      Returns Promise<T>

      The resource that was created or updated.