Hierarchy

  • default
    • DigitalAssets

Constructors

  • Parameters

    • __namedParameters: EndpointOptions

    Returns DigitalAssets

Methods

  • Returns a stream for downloading a purchased digital product. See api docs.

    Required token: Bearer token or Order token

    Options schema:

    interface options {
    asset_token: string
    }

    Success response schema: Success schema

    Failure response schema: Error schema

    Example:

    // Many NodeJS servers allow piping a stream as the response (`digitalAssetStream.pipe(serverResponse);`).

    // The below example assumes a logged in user using SpreeSDK in the browser and downloading an image asset.

    // A digital token can be retrieved from a digital link associated to a line item in a completed order.
    const digitalToken = '1YjXK36ZRj2w4nxtMkJutTGX'

    const response = await client.digitalAssets.download({
    bearer_token: '7381273269536713689562374856',
    asset_token: digitalToken
    })

    const digitalAssetStream = response.success()

    // Append an <img> tag to the page to show the asset on the page.
    const image = new Image()

    document.body.appendChild(image)

    // Convert a stream to a Blob for easier processing.
    const digitalAssetBlob = await new Response(digitalAssetStream).blob()

    image.src = URL.createObjectURL(digitalAssetBlob)

    Parameters

    • options: DownloadOptions

    Returns Promise<DigitalAssetResult>

  • Type Parameters

    • ResponseType = JsonApiResponse

    Parameters

    • method: HttpMethod
    • url: string
    • Optional tokens: IToken
    • Optional params: any
    • Optional responseParsing: ResponseParsing

    Returns Promise<ResultResponse<ResponseType>>

  • The HTTP error code returned by Spree is not indicative of its response shape. This function determines the information provided by Spree and uses everything available.

    Parameters

    • error: default

    Returns ErrorType

  • Parameters

    • error: Error

    Returns default

  • Parameters

    • error: default

    Returns default

  • Parameters

    • tokens: IToken

    Returns {
        [headerName: string]: string;
    }

    • [headerName: string]: string

Properties

fetcher: Fetcher

Generated using TypeDoc