Skip to content

createPurchase TypeScript overload missing for options parameter accepted by JS implementation #370

Description

@lancefallon

The JavaScript implementation of createPurchase in Client.js accepts a second options argument (passed through to _makeRequest → _getRequestOptions) that supports custom headers:

async createPurchase (body, options = {}) { let path = '/purchases' path = this._interpolatePath(path) return this._makeRequest('POST', path, body, options) }

However, the TypeScript declaration only exposes one parameter:

createPurchase(body: PurchaseCreate): Promise<InvoiceCollection>;

This matters in practice when adding an Idempotency-Key header to requests. The only way to pass this is via options.headers, but TypeScript users have no type-safe way to do so.

For reference, the Go SDK exposes this via a first-class WithIdempotencyKey option.

Suggested fix:
createPurchase(body: PurchaseCreate, options?: { headers?: Record<string, string> }): Promise<InvoiceCollection>;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions