Skip to content

Instantly share code, notes, and snippets.

@mwawrusch
Created November 24, 2015 12:17
Show Gist options
  • Save mwawrusch/65d9f95f680e65d5a25d to your computer and use it in GitHub Desktop.
Save mwawrusch/65d9f95f680e65d5a25d to your computer and use it in GitHub Desktop.
_ = require 'underscore'
Hoek = require 'hoek'
transloadit = require 'transloadit'
###
Sends a post request to transloadit to start image processing.
###
module.exports = (testMode,authKey,authSecret,templateId,notifyUrl,sourceUrl,productFeedId,cb) ->
Hoek.assert _.isString(authKey),"The required parameter authKey is missing or not a string."
Hoek.assert _.isString(authSecret), "The required parameter authSecret is missing or not a string."
Hoek.assert _.isString(templateId),"The required parameter templateId is missing or not a string."
Hoek.assert _.isString(notifyUrl),"The required parameter notifyUrl is missing or not a string."
Hoek.assert _.isString(sourceUrl),"The required parameter sourceUrl is missing or not a string."
Hoek.assert _.isString(productFeedId),"The required parameter productFeedId is missing or not a string."
Hoek.assert _.isFunction(cb),"The required parameter cb is missing or not a function."
return cb null if testMode
transloaditClient = new transloadit
authKey : authKey
authSecret: authSecret
assemblyOptions =
params:
productFeedId: productFeedId
template_id: templateId
notify_url: notifyUrl
steps:
import:
url: sourceUrl
transloaditClient.createAssembly assemblyOptions, (err, result) ->
return cb err if err
cb null, result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment