chargebee / chargebee-node

Node.js library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=node
MIT License
46 stars 30 forks source link

Convenient list endpoints func #24

Closed KevinDanikowski closed 1 year ago

KevinDanikowski commented 3 years ago

I wanted a convenient way to use JS intellisense to see the functions available. I edited the bottom of lib/chargebee like so to produce a JSON output here which outlines the functions in a slightly easier to read way. (run node lib/chargebee.js) (this is based on 2.6.5)

const fs = require('fs')
let methods = {}
;(function() {
  module.exports.configure = ChargeBee.configure
  for (var res in ChargeBee._endpoints) {
    module.exports[res] = {}
    methods[res] = {}
    var apiCalls = ChargeBee._endpoints[res]
    for (var apiIdx = 0; apiIdx < apiCalls.length; apiIdx++) {
      var metaArr = apiCalls[apiIdx]
      var apiCall = {
        methodName: metaArr[0],
        httpMethod: metaArr[1],
        urlPrefix: metaArr[2],
        urlSuffix: metaArr[3],
        hasIdInUrl: metaArr[4],
        isListReq: metaArr[0] === 'list',
      }
      methods[res][apiCall.methodName] = {
        methodName: metaArr[0],
        httpMethod: metaArr[1],
        urlPrefix: metaArr[2],
        urlSuffix: metaArr[3],
        hasIdInUrl: metaArr[4],
        isListReq: metaArr[0] === 'list',
      }

      module.exports[res][apiCall.methodName] = createApiFunc(apiCall)
    }
  }
  fs.writeFileSync('./exports.json', JSON.stringify(methods), 'utf-8')
  module.exports.time_machine.wait_for_time_travel_completion = ChargeBee._timeMachineWait
  module.exports.export.wait_for_export_completion = ChargeBee._waitForExport
})()
cb-tamizhvendansembiyan commented 1 year ago

@KevinDanikowski We are incredibly sorry for the delayed response. Unfortunately, we failed to address this earlier as we would have wished.

I wanted a convenient way to use JS intellisense to see the functions available.

We have addressed these intellisense-related queries recently by leveraging Typescript Types.

image

Once again sorry for the delayed response and thanks for reporting this issue.