Class TierWithClock

The Tier client, main interface provided by the SDK.

All methods are re-exported as top level functions by the main package export, in such a way that they create a client and spin up a Tier sidecar process on demand.

Hierarchy

Constructors

Properties

apiKey: string

API key for use with the hosted service on tier.run

baseURL: string

The URL to the sidecar providing API endpoints

clockID: string

The ID of a stripe test clock. Set via withClock

fetch: ((input: URL | RequestInfo, init?: RequestInit) => Promise<Response>)

Type declaration

    • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
    • The fetch() implementation in use. Will default to the Node built-in fetch if available, otherwise node-fetch will be used.

      Parameters

      • input: URL | RequestInfo
      • Optional init: RequestInit

      Returns Promise<Response>

onError?: ((er: TierError) => any)

Type declaration

    • (er: TierError): any
    • A method which is called on all errors, useful for logging, or handling 401 responses from a public tier API.

      Parameters

      Returns any

signal?: AbortSignal

AbortSignal used to cancel all requests from this client.

userAgent?: string | false

The User-Agent header that Tier sends.

Set to false to not send a user agent header. Leave blank to send the default User-Agent header, which includes the Tier client version, along with either Node.js process.version or browser's navigator.userAgent

Accessors

  • set debug(d: boolean): void
  • Parameters

    • d: boolean

    Returns void

Methods

  • Returns Promise<void>

  • Parameters

    • t: Date

    Returns Promise<void>

  • Type Parameters

    • T

    Parameters

    • path: string
    • Optional query: {
          [k: string]: string | string[];
      }
      • [k: string]: string | string[]

    Returns Promise<T>

  • Type Parameters

    • TReq

    • TRes = {}

    Parameters

    • path: string
    • body: TReq

    Returns Promise<TRes>

  • Return an Answer indicating whether an org can access a feature, or if they are at their plan limit.

    Parameters

    • org: `org:${string}`
    • feature: `feature:${string}`

    Returns Promise<Answer>

  • Generate a checkout URL to set an org's payment info, and optionally to create a subscription on completion.

    successUrl param should be a URL within your application where the user will be redirected upon completion.

    Parameters

    Returns Promise<CheckoutResponse>

  • Deprecated

    alias for lookupLimit

    Parameters

    • org: `org:${string}`
    • feature: `feature:${string}`

    Returns Promise<Usage>

  • Similar to pull, but filters plans to only include the highest version of each plan. Plan versions are sorted numerically if they are decimal integers, or lexically in the en locale otherwise.

    So, for example, the plan version 20test will be considered "lower" than 9test, because the non-numeric string causes it to be lexically sorted. But the plan version 20 sill be considered "higher" than the plan version 9, because both are strictly numeric.

    Note Plan versions are inherently arbitrary, and as such, they really should not be sorted or given any special priority by being "latest".

    This method will be removed in version 6 of this SDK.

    Deprecated

    Returns Promise<Model>

  • Report metered feature usage

    Parameters

    • org: `org:${string}`
    • feature: `feature:${string}`
    • n: number = 1
    • __namedParameters: ReportParams = {}

    Returns Promise<{}>

  • Type Parameters

    • T

    Parameters

    • path: string
    • Optional query: {
          [k: string]: string | string[];
      }
      • [k: string]: string | string[]

    Returns Promise<T>

  • Type Parameters

    • TReq

    • TRes = {}

    Parameters

    • path: string
    • body: TReq

    Returns Promise<TRes>

Generated using TypeDoc