nulab / backlog-js

Backlog API version 2 client for browser and node.
https://developer.nulab-inc.com/docs/backlog/
33 stars 13 forks source link

Some `*IdOrKey` parameters type are different from official references. #42

Closed mmktomato closed 3 years ago

mmktomato commented 3 years ago

For example,

https://github.com/nulab/backlog-js/blob/3e9f817b2b2014ece946e0cbd35781bcb7e65ba9/src/backlog.ts#L303

projectIdOrKey: string|number

but in reference,

projectIdOrKey String

One more example.

https://github.com/nulab/backlog-js/blob/3e9f817b2b2014ece946e0cbd35781bcb7e65ba9/src/option.ts#L540

projectIdOrKey: number

but in reference,

projectIdOrKey String

I think backlog-js should follow the references.

mmktomato commented 3 years ago

These three's *IdOrKey parameters are in request body. The endpoints accept both project id (number) and project key (string). So the parameters should be string | number.

The others' *IdOrKey parameters are in request path. For example:

  public getIssue(issueIdOrKey: string | number): Promise<any> {
    return this.get(`issues/${issueIdOrKey}`);
  }

If you pass project key (string) to it, the path is issues/MY_PROJ_KEY. If you pass project id (number) to it, the path is issues/12345. The endpoints accept both. So the parameters should be string | number.

Conclusion: string | number for all *IdOrKey parameters in this library.