/*! Compiled/Compressed version of carvoyant (Version: 0.0.5) created on 08-05-2014 */ !function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.carvoyant=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g-1?new TypeError(b+" must be a Date."):c}}),this.makeRequest("/vehicle/"+a+"/trip","get",b,d)},d.prototype.makeRequest=function(a,b,c,d){this.accessToken&&"/"!==a.slice(-1)&&(a+="/");var e=g["delete"!==b?b:"del"](this.apiUrl+a),h=["asc","desc"];if(!f.isUndefined(c)&&!f.isNull(c)&&!f.isFunction(c))throw new TypeError("cb must be a Function.");d=d||{},f.each(d,function(a,c){var d={};if(!f.isUndefined(a)){if("sortOrder"===c&&!f.contains(h,a))throw new TypeError(c+" must be one of the following: "+h.join(", "));if(("searchLimit"===c||"searchOffset"===c)&&!f.isNumber(a))throw new TypeError(c+" must be a Number.");d[c]=a,"POST"===b.toUpperCase()?e.send(d):e.query(d)}}),this.accessToken?e.set("Authorization","Bearer "+this.accessToken):e.auth(this.apiKey,this.securityToken),e.end(function(a){c&&c(a)})},d.prototype.makeActionRequest=function(a,b,c){var d=f.isUndefined(a.req.path)?a.req.url.replace(this.apiUrl,""):a.req.path;d.indexOf("/api")>-1&&(d=d.split("/api")[1]),this.makeRequest(d.split("?")[0],a.req.method.toLowerCase(),c,h.actionQueryParams(a,b))},d.prototype.nextPage=function(a,b){this.makeActionRequest(a,"next",b)},d.prototype.prevPage=function(a,b){this.makeActionRequest(a,"previous",b)},c.Client=d,c.createClient=e},{"./utils":3,"lodash.assign":4,"lodash.contains":27,"lodash.foreach":108,"lodash.isboolean":134,"lodash.isdate":135,"lodash.isfunction":136,"lodash.isnull":137,"lodash.isnumber":138,"lodash.isundefined":142,superagent:143}],3:[function(a,b,c){"use strict";var d={contains:a("lodash.contains"),each:a("lodash.foreach"),find:a("lodash.find"),isDate:a("lodash.isdate"),isFunction:a("lodash.isfunction"),isObject:a("lodash.isobject"),isString:a("lodash.isstring"),isUndefined:a("lodash.isundefined")},e={GEOFENCE:"geoFence",LOWBATTERY:"lowBattery",NUMERICDATAKEY:"numericDataKey",TIMEOFDAY:"timeOfDay",TROUBLECODE:"troubleCode"};c.actionQueryParams=function(a,b){var e,f={booleans:["includeData"],timestamps:["endTime","startTime"],numbers:["searchLimit","searchOffset"]},g={};if(d.isUndefined(b))throw new TypeError("actionName must be defined.");if(!d.isString(b))throw new TypeError("actionName must be a String.");if(d.isUndefined(a))throw new TypeError("res must be defined.");if(!d.isObject(a))throw new TypeError("res must be an Object.");if(e=d.find(a.body.actions,function(a){return a.name===b}),d.isUndefined(e))throw new TypeError("No action found for name: "+b);return d.each((e.uri.indexOf("?")>-1?e.uri.split("?")[1]:"").split("#")[0].split("&"),function(a){var b=a.split("="),e=decodeURIComponent(b[0].replace(/\+/g," ")),h=2===b.length?decodeURIComponent(b[1].replace(/\+/g," ")):void 0;d.contains(f.booleans,e)?g[e]="true"===h?!0:!1:d.contains(f.timestamps,e)?g[e]=c.dateToTimestamp(new Date(h)):d.contains(f.numbers,e)&&(g[e]=parseInt(h,10))}),g},c.timestampToDate=function(a){if(d.isUndefined(a))throw new TypeError("timestamp must be defined.");if(!d.isString(a))throw new TypeError("timestamp must be a String.");var b=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})([+-])(\d{4})/.exec(a);if(!b)throw new TypeError("timestamp did not match expected format (yyyyMMddTHHmmssZ).");return new Date(b[1]+"-"+b[2]+"-"+b[3]+"T"+b[4]+":"+b[5]+":"+b[6]+b[7]+b[8])},c.dateToTimestamp=function(a){if(d.isUndefined(a))throw new TypeError("date must be defined.");if(!d.isDate(a))throw new TypeError("date must be a Date.");var b=function(a){return 10>a?"0"+a:a.toString()},c=a.getTimezoneOffset()/60,e=a.getTimezoneOffset()%60;return[a.getFullYear(),b(a.getMonth()+1),b(a.getDate()),"T",b(a.getHours()),b(a.getMinutes()),b(a.getSeconds()),a.getTimezoneOffset()>0?"-":"+",b(c)+b(e)].join("")},c.externalizeEventType=function(a){var b=e[a];return b?b:a}},{"lodash.contains":27,"lodash.find":52,"lodash.foreach":108,"lodash.isdate":135,"lodash.isfunction":136,"lodash.isobject":139,"lodash.isstring":141,"lodash.isundefined":142}],4:[function(a,b){var c=a("lodash._basecreatecallback"),d=a("lodash.keys"),e=a("lodash._objecttypes"),f=function(a,b,f){var g,h=a,i=h;if(!h)return i;var j=arguments,k=0,l="number"==typeof f?2:j.length;if(l>3&&"function"==typeof j[l-2])var m=c(j[--l-1],j[l--],2);else l>2&&"function"==typeof j[l-1]&&(m=j[--l]);for(;++k2?d(a,17,e(arguments,2),null,b):d(a,1,null,null,b)}var d=a("lodash._createwrapper"),e=a("lodash._slice");b.exports=c},{"lodash._createwrapper":10,"lodash._slice":19}],10:[function(a,b){function c(a,b,h,k,l,m){var n=1&b,o=2&b,p=4&b,q=16&b,r=32&b;if(!o&&!f(a))throw new TypeError;q&&!h.length&&(b&=-17,q=h=!1),r&&!k.length&&(b&=-33,r=k=!1);var s=a&&a.__bindData__;if(s&&s!==!0)return s=g(s),s[2]&&(s[2]=g(s[2])),s[3]&&(s[3]=g(s[3])),!n||1&s[1]||(s[4]=l),!n&&1&s[1]&&(b|=8),!p||4&s[1]||(s[5]=m),q&&i.apply(s[2]||(s[2]=[]),h),r&&j.apply(s[3]||(s[3]=[]),k),s[1]|=b,c.apply(null,s);var t=1==b||17===b?d:e;return t([a,b,h,k,l,m])}var d=a("lodash._basebind"),e=a("lodash._basecreatewrapper"),f=a("lodash.isfunction"),g=a("lodash._slice"),h=[],i=h.push,j=h.unshift;b.exports=c},{"lodash._basebind":11,"lodash._basecreatewrapper":15,"lodash._slice":19,"lodash.isfunction":136}],11:[function(a,b){function c(a){function b(){if(h){var a=g(h);i.apply(a,arguments)}if(this instanceof b){var f=d(c.prototype),k=c.apply(f,a||arguments);return e(k)?k:f}return c.apply(j,a||arguments)}var c=a[0],h=a[2],j=a[4];return f(b,a),b}var d=a("lodash._basecreate"),e=a("lodash.isobject"),f=a("lodash._setbinddata"),g=a("lodash._slice"),h=[],i=h.push;b.exports=c},{"lodash._basecreate":12,"lodash._setbinddata":6,"lodash._slice":19,"lodash.isobject":139}],12:[function(a,b){(function(c){function d(a){return f(a)?g(a):{}}var e=a("lodash._isnative"),f=a("lodash.isobject"),g=(a("lodash.noop"),e(g=Object.create)&&g);g||(d=function(){function a(){}return function(b){if(f(b)){a.prototype=b;var d=new a;a.prototype=null}return d||c.Object()}}()),b.exports=d}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"lodash._isnative":13,"lodash.isobject":139,"lodash.noop":14}],13:[function(a,b){b.exports=a(7)},{}],14:[function(a,b){b.exports=a(8)},{}],15:[function(a,b){function c(a){function b(){var a=o?m:this;if(k){var f=g(k);i.apply(f,arguments)}if((l||q)&&(f||(f=g(arguments)),l&&i.apply(f,l),q&&f.lengthe?0:e);++dc?h(0,k+c):c)||0,f(a)?l=j(a,b,c)>-1:"number"==typeof k?l=(g(a)?a.indexOf(b,c):j(a,b,c))>-1:e(a,function(a){return++i>=c?!(l=a===b):void 0}),l}var d=a("lodash._baseindexof"),e=a("lodash.forown"),f=a("lodash.isarray"),g=a("lodash.isstring"),h=Math.max;b.exports=c},{"lodash._baseindexof":28,"lodash.forown":29,"lodash.isarray":132,"lodash.isstring":141}],28:[function(a,b){function c(a,b,c){for(var d=(c||0)-1,e=a?a.length:0;++d-1:void 0});return u.pop(),v.pop(),G&&(h(u),h(v)),w}var d=a("lodash.forin"),e=a("lodash._getarray"),f=a("lodash.isfunction"),g=a("lodash._objecttypes"),h=a("lodash._releasearray"),i="[object Arguments]",j="[object Array]",k="[object Boolean]",l="[object Date]",m="[object Number]",n="[object Object]",o="[object RegExp]",p="[object String]",q=Object.prototype,r=q.toString,s=q.hasOwnProperty;b.exports=c},{"lodash._getarray":73,"lodash._objecttypes":75,"lodash._releasearray":76,"lodash.forin":79,"lodash.isfunction":136}],73:[function(a,b){function c(){return d.pop()||[]}var d=a("lodash._arraypool");b.exports=c},{"lodash._arraypool":74}],74:[function(a,b){var c=[];b.exports=c},{}],75:[function(a,b){b.exports=a(23)},{}],76:[function(a,b){function c(a){a.length=0,d.lengthf;++f)c=e[f],b=c.split("="),d[decodeURIComponent(b[0])]=decodeURIComponent(b[1]);return d}function i(a){var b,c,d,e,f=a.split(/\r?\n/),g={};f.pop();for(var h=0,i=f.length;i>h;++h)c=f[h],b=c.indexOf(":"),d=c.slice(0,b).toLowerCase(),e=r(c.slice(b+1)),g[d]=e;return g}function j(a){return a.split(/ *; */).shift()}function k(a){return p(a.split(/ *; */),function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})}function l(a,b){b=b||{},this.req=a,this.xhr=this.req.xhr,this.text=this.xhr.responseText,this.setStatusProperties(this.xhr.status),this.header=this.headers=i(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text):null}function m(a,b){var c=this;o.call(this),this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.on("end",function(){var b=new l(c);"HEAD"==a&&(b.text=null),c.callback(null,b)})}function n(a,b){return"function"==typeof b?new m("GET",a).end(b):1==arguments.length?new m("GET",a):new m(a,b)}var o=a("emitter"),p=a("reduce"),q="undefined"==typeof window?this:window,r="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};n.serializeObject=g,n.parseString=h,n.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},n.serialize={"application/x-www-form-urlencoded":g,"application/json":JSON.stringify},n.parse={"application/x-www-form-urlencoded":h,"application/json":JSON.parse},l.prototype.get=function(a){return this.header[a.toLowerCase()]},l.prototype.setHeaderProperties=function(){var a=this.header["content-type"]||"";this.type=j(a);var b=k(a);for(var c in b)this[c]=b[c]},l.prototype.parseBody=function(a){var b=n.parse[this.type];return b?b(a):null},l.prototype.setStatusProperties=function(a){var b=a/100|0;this.status=a,this.statusType=b,this.info=1==b,this.ok=2==b,this.clientError=4==b,this.serverError=5==b,this.error=4==b||5==b?this.toError():!1,this.accepted=202==a,this.noContent=204==a||1223==a,this.badRequest=400==a,this.unauthorized=401==a,this.notAcceptable=406==a,this.notFound=404==a,this.forbidden=403==a },l.prototype.toError=function(){var a=this.req,b=a.method,c=a.url,d="cannot "+b+" "+c+" ("+this.status+")",e=new Error(d);return e.status=this.status,e.method=b,e.url=c,e},n.Response=l,o(m.prototype),m.prototype.use=function(a){return a(this),this},m.prototype.timeout=function(a){return this._timeout=a,this},m.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},m.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},m.prototype.set=function(a,b){if(f(a)){for(var c in a)this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},m.prototype.getHeader=function(a){return this._header[a.toLowerCase()]},m.prototype.type=function(a){return this.set("Content-Type",n.types[a]||a),this},m.prototype.accept=function(a){return this.set("Accept",n.types[a]||a),this},m.prototype.auth=function(a,b){var c=btoa(a+":"+b);return this.set("Authorization","Basic "+c),this},m.prototype.query=function(a){return"string"!=typeof a&&(a=g(a)),a&&this._query.push(a),this},m.prototype.field=function(a,b){return this._formData||(this._formData=new FormData),this._formData.append(a,b),this},m.prototype.attach=function(a,b,c){return this._formData||(this._formData=new FormData),this._formData.append(a,b,c),this},m.prototype.send=function(a){var b=f(a),c=this.getHeader("Content-Type");if(b&&f(this._data))for(var d in a)this._data[d]=a[d];else"string"==typeof a?(c||this.type("form"),c=this.getHeader("Content-Type"),this._data="application/x-www-form-urlencoded"==c?this._data?this._data+"&"+a:a:(this._data||"")+a):this._data=a;return b?(c||this.type("json"),this):this},m.prototype.callback=function(a,b){var c=this._callback;return 2==c.length?c(a,b):a?this.emit("error",a):void c(b)},m.prototype.crossDomainError=function(){var a=new Error("Origin is not allowed by Access-Control-Allow-Origin");a.crossDomain=!0,this.callback(a)},m.prototype.timeoutError=function(){var a=this._timeout,b=new Error("timeout of "+a+"ms exceeded");b.timeout=a,this.callback(b)},m.prototype.withCredentials=function(){return this._withCredentials=!0,this},m.prototype.end=function(a){var b=this,f=this.xhr=e(),g=this._query.join("&"),h=this._timeout,i=this._formData||this._data;if(this._callback=a||c,f.onreadystatechange=function(){return 4==f.readyState?0==f.status?b.aborted?b.timeoutError():b.crossDomainError():void b.emit("end"):void 0},f.upload&&(f.upload.onprogress=function(a){a.percent=a.loaded/a.total*100,b.emit("progress",a)}),h&&!this._timer&&(this._timer=setTimeout(function(){b.abort()},h)),g&&(g=n.serializeObject(g),this.url+=~this.url.indexOf("?")?"&"+g:"?"+g),f.open(this.method,this.url,!0),this._withCredentials&&(f.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof i&&!d(i)){var j=n.serialize[this.getHeader("Content-Type")];j&&(i=j(i))}for(var k in this.header)null!=this.header[k]&&f.setRequestHeader(k,this.header[k]);return this.emit("request",this),f.send(i),this},n.Request=m,n.get=function(a,b,c){var d=n("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},n.head=function(a,b,c){var d=n("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},n.del=function(a,b){var c=n("DELETE",a);return b&&c.end(b),c},n.patch=function(a,b,c){var d=n("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},n.post=function(a,b,c){var d=n("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},n.put=function(a,b,c){var d=n("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},b.exports=n},{emitter:144,reduce:145}],144:[function(a,b){function c(a){return a?d(a):void 0}function d(a){for(var b in c.prototype)a[b]=c.prototype[b];return a}b.exports=c,c.prototype.on=c.prototype.addEventListener=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks[a]=this._callbacks[a]||[]).push(b),this},c.prototype.once=function(a,b){function c(){d.off(a,c),b.apply(this,arguments)}var d=this;return this._callbacks=this._callbacks||{},c.fn=b,this.on(a,c),this},c.prototype.off=c.prototype.removeListener=c.prototype.removeAllListeners=c.prototype.removeEventListener=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c=this._callbacks[a];if(!c)return this;if(1==arguments.length)return delete this._callbacks[a],this;for(var d,e=0;ed;++d)c[d].apply(this,b)}return this},c.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},c.prototype.hasListeners=function(a){return!!this.listeners(a).length}},{}],145:[function(a,b){b.exports=function(a,b,c){for(var d=0,e=a.length,f=3==arguments.length?c:a[d++];e>d;)f=b.call(null,f,a[d],++d,a);return f}},{}],146:[function(a,b){b.exports={name:"carvoyant",description:"The Carvoyant API client library.",version:"0.0.5",author:{name:"Jeremy Whitlock",email:"jwhitlock@apache.org"},bugs:"https://github.com/whitlockjc/carvoyant/issues",homepage:"https://github.com/whitlockjc/carvoyant",licenses:[{type:"Apache-2.0",url:"http://www.apache.org/licenses/LICENSE-2.0"}],repository:{type:"git",url:"git://github.com/whitlockjc/carvoyant.git"},scripts:{test:"grunt nodeunit karma"},keywords:["carvoyant"],dependencies:{"lodash.assign":"~2.4.1","lodash.contains":"~2.4.1","lodash.find":"~2.4.1","lodash.foreach":"~2.4.1","lodash.isboolean":"~2.4.1","lodash.isdate":"~2.4.1","lodash.isfunction":"~2.4.1","lodash.isnull":"~2.4.1","lodash.isnumber":"~2.4.1","lodash.isobject":"~2.4.1","lodash.isstring":"~2.4.1","lodash.isundefined":"~2.4.1",superagent:"~0.18.0"},devDependencies:{browserify:"~3.46.0",grunt:"~0.4.4","grunt-browserify":"~2.0.8","grunt-contrib-clean":"~0.5.0","grunt-contrib-jshint":"~0.10.0","grunt-contrib-nodeunit":"~0.3.3","grunt-contrib-uglify":"~0.4.0","grunt-jsdoc":"~0.5.4","grunt-karma":"~0.8.3","grunt-release":"~0.7.0",karma:"~0.12.14","karma-chrome-launcher":"~0.1.3","karma-coffee-preprocessor":"~0.2.1","karma-firefox-launcher":"~0.1.3","karma-html2js-preprocessor":"~0.1.0","karma-jasmine":"~0.1.5","karma-nodeunit":"~0.1.1","karma-phantomjs-launcher":"~0.1.4","karma-requirejs":"~0.2.1","karma-script-launcher":"~0.1.0","lodash.isarray":"~2.4.1","lodash.map":"~2.4.1"},main:"lib/carvoyant",engines:{node:">= 0.8.0"}}},{}]},{},[1])(1)});