Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Incorrect typedefs #299

Open
a-ogilvie opened this issue Mar 29, 2021 · 1 comment
Open

Incorrect typedefs #299

a-ogilvie opened this issue Mar 29, 2021 · 1 comment

Comments

@a-ogilvie
Copy link

I found a typedef that does not match the actual function that it describes.

From /lib/list.js:

  getContacts(id, options) {
    if (!id) {
      return Promise.reject(new Error('id parameter must be provided.'))
    }

    return this.client.apiRequest({
      method: 'GET',
      path: `/contacts/v1/lists/${id}/contacts/all`,
      qs: options,
      qsStringifyOptions: { indices: false },
    })
  }

From /typescript/list.ts:

  getContacts(id: number): RequestPromise

Note that the actual function takes two arguments, but the typedef only describes one argument. This causes an error to be thrown when passing an options argument to `getContacts.

Are there other functions where the typedef is incorrect? Should I open a PR to bring these in sync?

@kev-supapass
Copy link

I've just found another typedef that is incorrect on tickets.

The ITicket type is correct for V3 of the hubspot api.

from /typescript/tickets.ts:

export interface ITicket {
  subject: string
  content: string
  due_date: number
  hs_ticket_priority: string
  hs_pipeline: number
  hs_pipeline_stage: number
}
....
create(data: ITicket): RequestPromise

but in /tickets.js:

  create(data) {
    return this.client.apiRequest({
      method: 'POST',
      path: '/crm-objects/v1/objects/tickets',
      body: data,
    })
  }

We're hitting the V1 of the hubspot api.

This version requires an array of objects with a name and value.

[
  {
    "name": "subject",
    "value": "This is an example ticket"
  },
  {
    "name": "content",
    "value": "Here are the details of the ticket."
  },
  {
    "name": "hs_pipeline",
    "value": "0"
  },
  {
    "name": "hs_pipeline_stage",
    "value": "1"
  }
]

So we can either change tickets.js to use V3, or change the type to match V1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants