'use strict'

const {encode, isFunction, isString, isObject} = require('./helpers')

module.exports = class Validations {
  constructor (client, promotionsNamespace) {
    this.client = client
    this.promotions = promotionsNamespace
  }

  validateVoucher (code, params = {}, callback = null) {
    if (isFunction(params)) {
      callback = params
      params = {}
    }

    return this.client.post(`/vouchers/${encode(code)}/validate`, params, callback)
  }

  validate (code, context = {}, callback = null) {
    if (isString(code)) {
      return this.validateVoucher(code, context, callback)
    } else if (isObject(code)) {
      if (isFunction(context)) {
        callback = context
      }

      return this.promotions.validate(code, callback)
    }
  }
}

@@ -520,100 +520,8 @@
  if 
-(isString(code)) %7B%0A      return this.validateVoucher(code, context, callback)%0A    %7D else if 
 (isO
@@ -599,25 +599,24 @@
 ext%0A      %7D%0A
-%0A
       return
@@ -662,15 +662,73 @@
 k)%0A    %7D
+%0A%0A    return this.validateVoucher(code, context, callback)
 %0A  %7D%0A%7D%0A

Fix voucher validation vulnerability