validator = require('validator').validators

module.exports = {
  Gateway: (function(){
    function Client(opts){
      this.clientId = this.validate(opts, 'clientId', 'isAlphanumeric')
      this.clientSecret = this.validate(opts, 'clientSecret', 'isAlphanumeric')
      this.api = this.validate(opts, 'api', 'isUrl')
    }

    Client.prototype.validate = function(opts, value, predicate) {
      function throwError() {
        throw new Error('params: '+value+' fails '+predicate+' test.')
      }

      validator['isBoolean'] = function(val) {
        return (val == true)   || (val == false) ||
               (val == 'true') || (val == 'false')
      }

      console.log(value, opts[value])
      if (!!value) {  
        if (predicate == 'present') { return true }
      } else {
        throwError() 
      }
      try {
        if (validator[predicate](opts[value])) {
          return value
        } else { 
          throwError()
        }
      } catch(e) {
        throwError()
      }
    }

    Client.prototype.createRippleTransaction = function(opts, fn){
      params = {
        toCurrency: this.validate(opts,'toCurrency', 'isAlphanumeric'),
        fromCurrency: this.validate(opts, 'fromCurrency', 'isAlphanumeric'),
        toAmount: this.validate(opts, 'toAmount', 'isDecimal'),
        fromAmount: this.validate(opts, 'fromAmount', 'isDecimal'),
        toIssuer: this.validate(opts, 'toIsser', 'present'),
        fromIssuer: this.validate(opts, 'fromIssuer', 'present'),
        fromAddress: this.validate(opts, 'fromAddress', 'present'),
        toAddress: this.validate(opts, 'toAddress', 'present'),
        sendTag: this.validate(opts, 'sendTag', 'isInt'),
        issuance: this.validate(opts, 'issuance', 'isBoolean'),
        txState: 'created'
      }

      
      fn(null, JSON.stringify({ success: true, rippleTransaction: params })) 
    }
    return {
      Client: Client
    }
  })()
}

@@ -36,16 +36,45 @@
 lidators
+%0Arequest = require('request')
 %0A%0Amodule
@@ -342,16 +342,45 @@
 isUrl')%0A
+      this.request = request%0A
     %7D%0A%0A 
@@ -718,46 +718,8 @@
  %7D%0A%0A
-      console.log(value, opts%5Bvalue%5D)%0A
     
@@ -1091,16 +1091,74 @@
 s, fn)%7B%0A
+      var resource = this.api + '/v1/ripple_transactions'%0A
       pa
@@ -1867,70 +1867,67 @@
   %7D%0A
-%0A
       
-%0A      fn(null, JSON.stringify(%7B success: true, 
+request.post(%7B url:'http://localhost:4000/v1/
 ripple
-T
+_t
 rans
@@ -1936,21 +1936,41 @@
 tion
-: params %7D)) 
+s', form:params, json:true %7D, fn)
 %0A   

Add POST to create ripple transaction in client lib.