avadev/AvaTax-REST-V2-JS-SDK

Questionable empty default parameter values

awhitford opened this issue · 3 comments

A number of methods have a questionable empty default parameter value, like this:

  /**
   * Reset this account's license key
   *
   * Resets the existing license key for this account to a new key.
     *  
     * To reset your account, you must specify the ID of the account you wish to reset and confirm the action.
     *  
     * This API is only available to account administrators for the account in question, and may only be called after
     * an account has been activated by reading and accepting Avalara's terms and conditions. To activate your account
     * please log onto the AvaTax website or call the `ActivateAccount` API.
     *  
     * You can only reset license with 'Default' license key name. 
     * Resetting a license key cannot be undone. Any previous license keys will immediately cease to work when a new key is created.
     *  
     * When you call this API, all account administrators for this account will receive an email with the newly updated license key.
     * The email will specify which user reset the license key and it will contain the new key to use to update your connectors.
     * Note: The reset license key functionality will only be available for existing active license key i.e. when you reset license key for the account, the Default license key will be reset.The reset license key functionality is not available for newly created license keys i.e. license keys other than Default
     * 
     * ### Security Policies
     * 
     * * This API requires one of the following user roles: AccountAdmin, Registrar, SiteAdmin, SSTAdmin, SystemAdmin, TechnicalSupportAdmin.
   *
   * 
     * @param int id The ID of the account you wish to update.
     * @param object model A request confirming that you wish to reset the license key of this account.
   * @return object
   */
  accountResetLicenseKey({ id, model } = {}) {
    var path = this.buildUrl({
      url: `/api/v2/accounts/${id}/resetlicensekey`,
      parameters: {}
    });
    return this.restCall({ url: path, verb: 'post', payload: model });
  }

In this example, the documentation states that "you must specify the ID of the account", so then why would an empty default value (= {}) make sense at all?

TypeScript will complain that:

'{}' is missing the following properties from type '{ id: number; model: object; }': id, model ts(2739)

I suggest reviewing them and removing them. Ultimately, the cleaner code will help with supporting TypeScript (#124).

We acknowledge that this is currently misleading. We are evaluation options to get it fixed and include TypeScript.
Thanks

The JavaScript Avatax SDK has existing limitations due to the fact that no models are present. When the caller is passing information to a method which will invoke the corresponding Avatax API, they have no idea what the model looks like or is expected without digging through the Avalara documentation on their own.

We have created a Typescript version of the Avatax SDK, which includes full support for models and enums. Javascript and Typescript developers will now get intelisense from any IDE which supports type files. Additionally, they will be able to navigate directly to the model definitions in the IDE and see exactly what is required and optional instead of having to look at some external documentation. We also added documentation for each method in the SDK which describes what the API does and other information.

The new version of the SDK is fully backwards compatible, so existing developers can take advantage of these new, useful features without having to make any changes to their code base.

We are looking for people willing to test out an early version of the SDK.

Steps to use:

  1. npm install ava-typescript --save
  2. Replace all require / imports to 'avatax' to 'ava-typescript'

Thank you.
cc: @awhitford

We have released the Typescript version of the JS SDK today (11/3/22), release 22.11.1. Please check it out we welcome any feedback. https://github.com/avadev/AvaTax-REST-V2-JS-SDK/releases/tag/22.11.1