ahmader / node-zoho

Zoho API access for NodeJS
21 stars 15 forks source link

Provide possibility to setup wfTrigger value and other request options #31

Closed pahan35 closed 6 years ago

pahan35 commented 6 years ago

As you see there is some extra parameters which we can provide with requests.

In some methods we can't setup this options. For example I need to setup wfTrigger: true on every Zoho insert action but I have no possibility to do it via method usage.

So I propose to change this

  insertRecords: (records, cb) ->
    if not _.isArray(records)
      throw new Error('Requires array of records')
    if records.length < 1
      throw new Error('Requires as least one record')

    query = {
      newFormat: 1,
      xmlData: @build(records)
  }

to this part

  insertRecords: (records, _query, cb) ->
    if not _.isArray(records)
      throw new Error('Requires array of records')
    if records.length < 1
      throw new Error('Requires as least one record')

    if _.isFunction(_query) 
      cb = _query
      _query = {}

    query = _.extend({
      newFormat: 1,
      xmlData: @build(records)
    }, _query)

It works perfectly and has backward compatibility. I will post pull request and try to add extra test for this case

ahmader commented 6 years ago

Fixed in #35