Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface RestClient<RT, CT, LP, CP, UP>

Rest client interface.

The Rest Client provides a consistent interface for interacting with a collection & resource. This is based off the typical REST API structure.

Type parameters

  • RT

    Record type

  • CT

    Collection type

  • LP

    List params

  • CP

    Create params

  • UP

    Update params

Hierarchy

  • RestClient

Index

Methods

  • create(params: CP): Promise<RT>
  • Create a new resource.

    Typically associated with POST /collection.

    Parameters

    • params: CP

      Create params.

    Returns Promise<RT>

    Promise of the created resource.

  • list(params?: LP): Promise<CT>
  • Fetch the collection

    Accepts a set of parameters which can be used to filter the collection. These params will be used as part of the cache key.

    Typically associated with GET /collection.

    Parameters

    • Optional params: LP

      List params

    Returns Promise<CT>

    Promise of a collection.

  • partial(id: string, params: Partial<UP>): Promise<RT>
  • Partially update a resource with the given params.

    Typically associated with PATCH /collection/:id.

    Parameters

    • id: string

      Id of the resource to partially update

    • params: Partial<UP>

      Values to update the resource with.

    Returns Promise<RT>

    Promise of the partially updated resource.

  • remove(id: string): Promise<void>
  • Delete a resource.

    Typically associated with DELETE /collection/:id.

    Parameters

    • id: string

      Id of the resource to delete.

    Returns Promise<void>

  • update(id: string, params: UP): Promise<RT>
  • Update a resource with the given params.

    Typically associated with PUT /collection/:id.

    Parameters

    • id: string

      Id of the resource to update

    • params: UP

      Values to update the resource with.

    Returns Promise<RT>

    Promise of the updated resource.

  • view(id: string): Promise<RT>
  • Fetch a resource with the given id.

    Typically associated with GET /collection/:id.

    Parameters

    • id: string

      Id of the resource to view.

    Returns Promise<RT>

    Promise of the viewed resource.

Generated using TypeDoc