Options
All
  • Public
  • Public/Protected
  • All
Menu

Customer API for adding custom functionality to websites and web apps with our Customer Portal.

IMPORTANT: this client is not compatible with the beta version of Customer API. If you're still on beta, please consider updating your code to the latest stable version. You can use @foxy.io/sdk prior to 1.0.0-beta.15 or a custom API client until you transition.

Hierarchy

Index

Constructors

Properties

_cache: Storage

Resolver cache implementing Web Storage API.

_console: Consola

Shared Consola instance.

_fetch: ((input: RequestInfo, init?: RequestInit) => Promise<Response>)

Custom Fetch API implementation for making authenticated requests.

Type declaration

_path: CurieChain

Path to this resource node as base URL followed by a list of curies.

base: URL

Bookmark URL for this API. This is where the tree traversal begins. We also use this URL as a base for relative paths.

cache: Storage

Resolver cache implementing Web Storage API. Every resolved path will be stored here for future use. You can clear this cache by calling clear().

console: Consola

Consola instance. If you extend this class and add logging in your code, use this instead of native console.

storage: Storage

Credentials storage implementing Web Storage API. Access tokens and other related info will be stored here. Clearing this storage will log you out.

AuthError: typeof AuthError = AuthError
Node: typeof Node = Node
ResolutionError: typeof ResolutionError = ResolutionError
Response: typeof Response = Response
SESSION: "session" = 'session'

Storage key for session data.

WHATWGHeaders: { prototype: Headers } = Headers

Polyfilled version of the built-in Headers class. If you need to pass an instance of Headers to .fetch(), use this class instead of the built-in one to avoid this issue.

Type declaration

  • prototype: Headers
WHATWGRequest: { prototype: Request } = Request

Polyfilled version of the built-in Request class. If you need to pass an instance of Request to .fetch(), use this class instead of the built-in one to avoid this issue.

Type declaration

WHATWGResponse: { prototype: Response; error: any; redirect: any } = Response

Polyfilled version of the built-in Response class. If you need to check the return value of .fetch(), use this class instead of the built-in one to avoid this issue.

Type declaration

  • prototype: Response
  • error:function
    • Returns Response

  • redirect:function
    • redirect(url: string, status?: number): Response
    • Parameters

      • url: string
      • Optional status: number

      Returns Response

v8n: { classConstructor: any } & { credentials: any; email: any; signUpParams: any } = ...

Validators for the method arguments in this class (internal).

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

Type declaration

Methods

  • _resolve(): Promise<URL>
  • Resolves resource URL from a curie chain. The first element in the path must be a URL.

    throws

    Throws {@link APIResolutionError} when once of the resources can't be reached.

    Returns Promise<URL>

    Resolved URL.

  • Resolves the URL of this node and sends a GET request using provided parameters.

    Returns Promise<Response<Customer.Graph, undefined>>

    Instance of {@link APIResponse} representing this resource.

  • Resolves the URL of this node and sends a GET request using provided parameters.

    Type Parameters

    Parameters

    • query: Q

      Query parameters such as zoom, fields etc.

    Returns Promise<Response<Customer.Graph, Q>>

    Instance of {@link APIResponse} representing this resource.

  • patch(body?: Partial<{ date_created: null | string; date_modified: null | string; email: string; first_name: string; id: number; last_login_date: string; last_name: string; tax_id: string }>): Promise<Response<Customer.Graph, undefined>>
  • Resolves the URL of this node and sends a PATCH request with provided properties, updating this resource.

    Parameters

    • Optional body: Partial<{ date_created: null | string; date_modified: null | string; email: string; first_name: string; id: number; last_login_date: string; last_name: string; tax_id: string }>

      Partial resource object.

    Returns Promise<Response<Customer.Graph, undefined>>

    Instance of {@link APIResponse} representing this resource.

  • post(body?: { date_created: null | string; date_modified: null | string; email: string; first_name: string; id: number; last_login_date: string; last_name: string; tax_id: string }): Promise<Response<Customer.Graph, undefined>>
  • Resolves the URL of this node and sends a POST request with provided properties, creating a resource or triggering an action.

    Parameters

    • Optional body: { date_created: null | string; date_modified: null | string; email: string; first_name: string; id: number; last_login_date: string; last_name: string; tax_id: string }

      Complete resource object.

      • date_created: null | string

        The date this resource was created.

      • date_modified: null | string

        The date this resource was last modified.

      • email: string

        The customer's email address. This is used as the login to the FoxyCart checkout for this customer.

      • first_name: string

        The customer's given name.

      • id: number

        The FoxyCart customer id, useful for Single Sign On integrations.

      • last_login_date: string

        The date of the last time this customer authenticated with the FoxyCart checkout.

      • last_name: string

        The customer's surname.

      • tax_id: string

        A tax identification number for this customer.

    Returns Promise<Response<Customer.Graph, undefined>>

    Instance of {@link APIResponse} representing this resource.

  • put(body?: { date_created: null | string; date_modified: null | string; email: string; first_name: string; id: number; last_login_date: string; last_name: string; tax_id: string }): Promise<Response<Customer.Graph, undefined>>
  • Resolves the URL of this node and sends a PUT request with provided properties, replacing the existing resource.

    Parameters

    • Optional body: { date_created: null | string; date_modified: null | string; email: string; first_name: string; id: number; last_login_date: string; last_name: string; tax_id: string }

      Complete resource object.

      • date_created: null | string

        The date this resource was created.

      • date_modified: null | string

        The date this resource was last modified.

      • email: string

        The customer's email address. This is used as the login to the FoxyCart checkout for this customer.

      • first_name: string

        The customer's given name.

      • id: number

        The FoxyCart customer id, useful for Single Sign On integrations.

      • last_login_date: string

        The date of the last time this customer authenticated with the FoxyCart checkout.

      • last_name: string

        The customer's surname.

      • tax_id: string

        A tax identification number for this customer.

    Returns Promise<Response<Customer.Graph, undefined>>

    Instance of {@link APIResponse} representing this resource.

  • sendPasswordResetEmail(params: { email: string }): Promise<void>
  • Initiates password reset for a customer with the given email. If such customer exists, they will receive an email from Foxy with further instructions.

    Parameters

    • params: { email: string }

      Password reset parameters.

      • email: string

        Customer email.

    Returns Promise<void>

  • Creates a Customer Portal session for a customer with the given credentials. Incorrect email and password will trigger Core.API.AuthError with code UNAUTHORIZED.

    Parameters

    • credentials: Credentials

      Customer email and password (one-time code).

    Returns Promise<void>

  • signOut(): Promise<void>
  • Creates a new customer account with the given credentials. If the email is already taken, Core.API.AuthError with code UNAVAILABLE will be thrown. If customer registration is disabled, Core.API.AuthError with code UNAUTHORIZED will be thrown. If the provided form data is invalid (e.g. captcha is expired), Core.API.AuthError with code INVALID_FORM will be thrown.

    Parameters

    Returns Promise<void>

Generated using TypeDoc