🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

srfax-node

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

srfax-node - npm Package Compare versions

Comparing version

to
0.1.3

@@ -1,1 +0,7 @@

export declare function getClient(): import("axios").AxiosInstance;
import { AxiosInstance } from 'axios';
/**
* Gets an axios client that is preconfigured to
* use the SRFax API URL.
* @returns {AxiosInstance}
*/
export declare function getClient(): AxiosInstance;
import { QueueFaxParams, QueueFaxResponse } from './types';
/**
* Submits a fax to the SRFax QUEUE_FAX API
* @param {QueueFaxParams} params The raw parameters for enqueueing a fax
* @returns {Promise<QueueFaxResponse>}
*/
export declare function queueFax(params: QueueFaxParams): Promise<QueueFaxResponse>;

@@ -29,1 +29,15 @@ export interface QueueFaxParams {

}
export interface NotifyRequestParams {
FaxDetailsID: number;
FileName: string;
SentStatus: string;
AccountCode?: string;
DateQueued: string;
DateSent: string;
ToFaxNumber: string;
Pages: number;
Duration: number;
RemoteID: string;
ErrorCode?: string;
Size: number;
}

@@ -47,7 +47,9 @@ import { QueueFaxRequest } from '../request/request';

setFileContent(fileContent: string): QueueFaxRequestBuilder;
setFile(filePath: string): QueueFaxRequestBuilder;
setNotifyURL(url: string): QueueFaxRequestBuilder;
setQueueFaxDate(date: string): QueueFaxRequestBuilder;
setQueueFaxTime(time: string): QueueFaxRequestBuilder;
setQueueFaxDateTime(date: Date): QueueFaxRequestBuilder;
build(): QueueFaxRequest;
}
export {};

@@ -8,3 +8,11 @@ 'use strict';

var axios = _interopDefault(require('axios'));
var path = _interopDefault(require('path'));
var fs = _interopDefault(require('fs'));
/**
* Gets an axios client that is preconfigured to
* use the SRFax API URL.
* @returns {AxiosInstance}
*/
function getClient() {

@@ -822,2 +830,8 @@ return axios.create({

/**
* Submits a fax to the SRFax QUEUE_FAX API
* @param {QueueFaxParams} params The raw parameters for enqueueing a fax
* @returns {Promise<QueueFaxResponse>}
*/
function queueFax(_x) {

@@ -1012,3 +1026,2 @@ return _queueFax.apply(this, arguments);

_proto.setFileContent = function setFileContent(fileContent) {
// TODO add methods to ingest file streams or blobs here
this.fileContent = fileContent;

@@ -1018,2 +1031,11 @@ return this;

_proto.setFile = function setFile(filePath) {
this.fileName = path.basename(filePath);
this.fileContent = fs.readFileSync(filePath, {
encoding: 'base64',
flag: 'r'
});
return this;
};
_proto.setNotifyURL = function setNotifyURL(url) {

@@ -1025,3 +1047,2 @@ this.notifyURL = url;

_proto.setQueueFaxDate = function setQueueFaxDate(date) {
// TODO must be in format YYYY-MM-DD
this.queueFaxDate = date;

@@ -1032,3 +1053,2 @@ return this;

_proto.setQueueFaxTime = function setQueueFaxTime(time) {
// TODO must be in format HH:MM and set with Date
this.queueFaxTime = time;

@@ -1038,2 +1058,16 @@ return this;

_proto.setQueueFaxDateTime = function setQueueFaxDateTime(date) {
if (date < new Date()) {
throw new Error('Queue date must be in the future');
}
var month = date.getMonth() > 9 ? "" + date.getMonth() : "0" + date.getMonth();
var day = date.getDate() > 9 ? "" + date.getDate() : "0" + date.getDate();
this.queueFaxDate = date.getFullYear() + "-" + month + "-" + day;
var hours = date.getHours() > 9 ? "" + date.getHours() : "0" + date.getHours();
var minutes = date.getMinutes() > 9 ? "" + date.getMinutes() : "0" + date.getMinutes();
this.queueFaxTime = hours + ":" + minutes;
return this;
};
_proto.build = function build() {

@@ -1040,0 +1074,0 @@ if (this.callerId === undefined || !this.senderEmail || !this.toFaxNumber || !this.faxType) {

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("axios"))&&"object"==typeof t&&"default"in t?t.default:t;function r(){return e.create({baseURL:"https://www.srfax.com/SRF_SecWebSvc.php"})}function n(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function s(t){n(a,o,i,s,u,"next",t)}function u(t){n(a,o,i,s,u,"throw",t)}s(void 0)}))}}function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var a,s=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new C(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var h={};function f(){}function l(){}function p(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(P([])));m&&m!==e&&r.call(m,o)&&(d=m);var y=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,s){var u=c(t[o],t,i);if("throw"!==u.type){var h=u.arg,f=h.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){h.value=t,a(h)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function F(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function b(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(F,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return l.prototype=y.constructor=p,p.constructor=l,l.displayName=s(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(x.prototype),x.prototype[i]=function(){return this},t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(y),s(y,a,"Generator"),y[o]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),b(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;b(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(a={exports:{}}),a.exports);function u(t){return c.apply(this,arguments)}function c(){return(c=o(s.mark((function t(e){var n;return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r(),t.next=3,n.post("",e);case 3:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var h=function(t){function e(e){var r;return(r=t.call(this)||this).params=e,r}return i(e,t),e.prototype.submit=function(){var t=o(s.mark((function t(){return s.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",u(this.params));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}((function(){})),f=function(t){function e(e,r){return t.call(this,e,r,"Queue_Fax")||this}i(e,t);var r=e.prototype;return r.setCallerId=function(t){return this.callerId=t,this},r.setSenderEmail=function(t){return this.senderEmail=t,this},r.setFaxType=function(t){switch(t){case"single":this.faxType="SINGLE";break;case"broadcast":this.faxType="BROADCAST"}return this},r.setToFaxNumber=function(t){return this.toFaxNumber=t,this},r.setResponseFormat=function(t){switch(t){case"json":this.responseFormat="JSON";break;case"xml":this.responseFormat="XML"}return this},r.setAccountCode=function(t){return this.accountCode=t,this},r.setRetries=function(t){if(t<0||t>6)throw new Error("invalid number of retries");return this.retries=t,this},r.setCoverPage=function(t){return this.coverPage=t,this},r.setFaxFromHeader=function(t){if(t.length>50)throw new Error("From header too long");return this.faxFromHeader=t,this},r.setCoverPageFromName=function(t){return this.CPFromName=t,this},r.setCoverPageToName=function(t){return this.CPToName=t,this},r.setCoverPageSubject=function(t){return this.CPSubject=t,this},r.setCoverPageOrg=function(t){return this.CPOrganization=t,this},r.setCoverPageComments=function(t){return this.CPComments=t,this},r.setFileName=function(t){return this.fileName=t,this},r.setFileContent=function(t){return this.fileContent=t,this},r.setNotifyURL=function(t){return this.notifyURL=t,this},r.setQueueFaxDate=function(t){return this.queueFaxDate=t,this},r.setQueueFaxTime=function(t){return this.queueFaxTime=t,this},r.build=function(){if(void 0===this.callerId||!this.senderEmail||!this.toFaxNumber||!this.faxType)throw new Error("missing required attribute");return new h({action:"Queue_Fax",access_id:this.accessId,access_pwd:this.accessPwd,sCallerID:this.callerId,sSenderEmail:this.senderEmail,sToFaxNumber:this.toFaxNumber,sFaxType:this.faxType,sResponseFormat:this.responseFormat,sAccountCode:this.accountCode,sRetries:this.retries,sCoverPage:this.coverPage,sFaxFromHeader:this.faxFromHeader,sCPFromName:this.CPFromName,sCPToName:this.CPToName,sCPOrganization:this.CPOrganization,sCPSubject:this.CPSubject,sCPComments:this.CPComments,sFileName_1:this.fileName,sFileContent_1:this.fileContent,sNotifyURL:this.notifyURL,sQueueFaxDate:this.queueFaxDate,sQueueFaxTime:this.queueFaxTime})},e}((function(t,e,r){this.action=r,this.accessId=t,this.accessPwd=e}));exports.QueueFaxRequest=h,exports.QueueFaxRequestBuilder=f,exports.getClient=r,exports.queueFax=u;
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("axios")),r=t(require("path")),n=t(require("fs"));function o(){return e.create({baseURL:"https://www.srfax.com/SRF_SecWebSvc.php"})}function i(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,o)}function a(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function s(t){i(a,n,o,s,u,"next",t)}function u(t){i(a,n,o,s,u,"throw",t)}s(void 0)}))}}function s(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var u,c=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new C(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var h={};function f(){}function l(){}function p(){}var d={};d[o]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(P([])));v&&v!==e&&r.call(v,o)&&(d=v);var y=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,s){var u=c(t[o],t,i);if("throw"!==u.type){var h=u.arg,f=h.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){h.value=t,a(h)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function F(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function b(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(F,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:L}}function L(){return{value:void 0,done:!0}}return l.prototype=y.constructor=p,p.constructor=l,l.displayName=s(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(x.prototype),x.prototype[i]=function(){return this},t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(y),s(y,a,"Generator"),y[o]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),b(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;b(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(u={exports:{}}),u.exports);function h(t){return f.apply(this,arguments)}function f(){return(f=a(c.mark((function t(e){var r;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=o(),t.next=3,r.post("",e);case 3:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var l=function(t){function e(e){var r;return(r=t.call(this)||this).params=e,r}return s(e,t),e.prototype.submit=function(){var t=a(c.mark((function t(){return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",h(this.params));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e}((function(){})),p=function(t){function e(e,r){return t.call(this,e,r,"Queue_Fax")||this}s(e,t);var o=e.prototype;return o.setCallerId=function(t){return this.callerId=t,this},o.setSenderEmail=function(t){return this.senderEmail=t,this},o.setFaxType=function(t){switch(t){case"single":this.faxType="SINGLE";break;case"broadcast":this.faxType="BROADCAST"}return this},o.setToFaxNumber=function(t){return this.toFaxNumber=t,this},o.setResponseFormat=function(t){switch(t){case"json":this.responseFormat="JSON";break;case"xml":this.responseFormat="XML"}return this},o.setAccountCode=function(t){return this.accountCode=t,this},o.setRetries=function(t){if(t<0||t>6)throw new Error("invalid number of retries");return this.retries=t,this},o.setCoverPage=function(t){return this.coverPage=t,this},o.setFaxFromHeader=function(t){if(t.length>50)throw new Error("From header too long");return this.faxFromHeader=t,this},o.setCoverPageFromName=function(t){return this.CPFromName=t,this},o.setCoverPageToName=function(t){return this.CPToName=t,this},o.setCoverPageSubject=function(t){return this.CPSubject=t,this},o.setCoverPageOrg=function(t){return this.CPOrganization=t,this},o.setCoverPageComments=function(t){return this.CPComments=t,this},o.setFileName=function(t){return this.fileName=t,this},o.setFileContent=function(t){return this.fileContent=t,this},o.setFile=function(t){return this.fileName=r.basename(t),this.fileContent=n.readFileSync(t,{encoding:"base64",flag:"r"}),this},o.setNotifyURL=function(t){return this.notifyURL=t,this},o.setQueueFaxDate=function(t){return this.queueFaxDate=t,this},o.setQueueFaxTime=function(t){return this.queueFaxTime=t,this},o.setQueueFaxDateTime=function(t){if(t<new Date)throw new Error("Queue date must be in the future");var e=t.getMonth()>9?""+t.getMonth():"0"+t.getMonth(),r=t.getDate()>9?""+t.getDate():"0"+t.getDate();this.queueFaxDate=t.getFullYear()+"-"+e+"-"+r;var n=t.getHours()>9?""+t.getHours():"0"+t.getHours(),o=t.getMinutes()>9?""+t.getMinutes():"0"+t.getMinutes();return this.queueFaxTime=n+":"+o,this},o.build=function(){if(void 0===this.callerId||!this.senderEmail||!this.toFaxNumber||!this.faxType)throw new Error("missing required attribute");return new l({action:"Queue_Fax",access_id:this.accessId,access_pwd:this.accessPwd,sCallerID:this.callerId,sSenderEmail:this.senderEmail,sToFaxNumber:this.toFaxNumber,sFaxType:this.faxType,sResponseFormat:this.responseFormat,sAccountCode:this.accountCode,sRetries:this.retries,sCoverPage:this.coverPage,sFaxFromHeader:this.faxFromHeader,sCPFromName:this.CPFromName,sCPToName:this.CPToName,sCPOrganization:this.CPOrganization,sCPSubject:this.CPSubject,sCPComments:this.CPComments,sFileName_1:this.fileName,sFileContent_1:this.fileContent,sNotifyURL:this.notifyURL,sQueueFaxDate:this.queueFaxDate,sQueueFaxTime:this.queueFaxTime})},e}((function(t,e,r){this.action=r,this.accessId=t,this.accessPwd=e}));exports.QueueFaxRequest=l,exports.QueueFaxRequestBuilder=p,exports.getClient=o,exports.queueFax=h;
//# sourceMappingURL=srfax-node.cjs.production.min.js.map
import axios from 'axios';
import path from 'path';
import fs from 'fs';
/**
* Gets an axios client that is preconfigured to
* use the SRFax API URL.
* @returns {AxiosInstance}
*/
function getClient() {

@@ -815,2 +823,8 @@ return axios.create({

/**
* Submits a fax to the SRFax QUEUE_FAX API
* @param {QueueFaxParams} params The raw parameters for enqueueing a fax
* @returns {Promise<QueueFaxResponse>}
*/
function queueFax(_x) {

@@ -1005,3 +1019,2 @@ return _queueFax.apply(this, arguments);

_proto.setFileContent = function setFileContent(fileContent) {
// TODO add methods to ingest file streams or blobs here
this.fileContent = fileContent;

@@ -1011,2 +1024,11 @@ return this;

_proto.setFile = function setFile(filePath) {
this.fileName = path.basename(filePath);
this.fileContent = fs.readFileSync(filePath, {
encoding: 'base64',
flag: 'r'
});
return this;
};
_proto.setNotifyURL = function setNotifyURL(url) {

@@ -1018,3 +1040,2 @@ this.notifyURL = url;

_proto.setQueueFaxDate = function setQueueFaxDate(date) {
// TODO must be in format YYYY-MM-DD
this.queueFaxDate = date;

@@ -1025,3 +1046,2 @@ return this;

_proto.setQueueFaxTime = function setQueueFaxTime(time) {
// TODO must be in format HH:MM and set with Date
this.queueFaxTime = time;

@@ -1031,2 +1051,16 @@ return this;

_proto.setQueueFaxDateTime = function setQueueFaxDateTime(date) {
if (date < new Date()) {
throw new Error('Queue date must be in the future');
}
var month = date.getMonth() > 9 ? "" + date.getMonth() : "0" + date.getMonth();
var day = date.getDate() > 9 ? "" + date.getDate() : "0" + date.getDate();
this.queueFaxDate = date.getFullYear() + "-" + month + "-" + day;
var hours = date.getHours() > 9 ? "" + date.getHours() : "0" + date.getHours();
var minutes = date.getMinutes() > 9 ? "" + date.getMinutes() : "0" + date.getMinutes();
this.queueFaxTime = hours + ":" + minutes;
return this;
};
_proto.build = function build() {

@@ -1033,0 +1067,0 @@ if (this.callerId === undefined || !this.senderEmail || !this.toFaxNumber || !this.faxType) {

{
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

# srfax-node
A basic NodeJS wrapper for the SRFax API.
A basic NodeJS wrapper for the SRFax API.
## API Documentation
Documentation for the SRFax API is available at https://www.srfax.com/developers/internet-fax-api

@@ -1,4 +0,9 @@

import axios from 'axios';
import axios, { AxiosInstance } from 'axios';
export function getClient() {
/**
* Gets an axios client that is preconfigured to
* use the SRFax API URL.
* @returns {AxiosInstance}
*/
export function getClient(): AxiosInstance {
return axios.create({

@@ -5,0 +10,0 @@ baseURL: 'https://www.srfax.com/SRF_SecWebSvc.php',

import { QueueFaxParams, QueueFaxResponse } from './types';
import { getClient } from './client';
/**
* Submits a fax to the SRFax QUEUE_FAX API
* @param {QueueFaxParams} params The raw parameters for enqueueing a fax
* @returns {Promise<QueueFaxResponse>}
*/
export async function queueFax(

@@ -5,0 +10,0 @@ params: QueueFaxParams

@@ -30,1 +30,16 @@ export interface QueueFaxParams {

}
export interface NotifyRequestParams {
FaxDetailsID: number;
FileName: string;
SentStatus: string;
AccountCode?: string;
DateQueued: string;
DateSent: string;
ToFaxNumber: string;
Pages: number;
Duration: number;
RemoteID: string;
ErrorCode?: string;
Size: number;
}
import { QueueFaxRequest } from '../request/request';
import path from 'path';
import fs from 'fs';
abstract class RequestBuilder<T> {

@@ -143,3 +144,2 @@ protected action: string;

setFileContent(fileContent: string): QueueFaxRequestBuilder {
// TODO add methods to ingest file streams or blobs here
this.fileContent = fileContent;

@@ -149,2 +149,11 @@ return this;

setFile(filePath: string): QueueFaxRequestBuilder {
this.fileName = path.basename(filePath);
this.fileContent = fs.readFileSync(filePath, {
encoding: 'base64',
flag: 'r',
});
return this;
}
setNotifyURL(url: string): QueueFaxRequestBuilder {

@@ -156,3 +165,2 @@ this.notifyURL = url;

setQueueFaxDate(date: string): QueueFaxRequestBuilder {
// TODO must be in format YYYY-MM-DD
this.queueFaxDate = date;

@@ -163,3 +171,2 @@ return this;

setQueueFaxTime(time: string): QueueFaxRequestBuilder {
// TODO must be in format HH:MM and set with Date
this.queueFaxTime = time;

@@ -169,2 +176,20 @@ return this;

setQueueFaxDateTime(date: Date): QueueFaxRequestBuilder {
if (date < new Date()) {
throw new Error('Queue date must be in the future');
}
const month =
date.getMonth() > 9 ? `${date.getMonth()}` : `0${date.getMonth()}`;
const day = date.getDate() > 9 ? `${date.getDate()}` : `0${date.getDate()}`;
this.queueFaxDate = `${date.getFullYear()}-${month}-${day}`;
const hours =
date.getHours() > 9 ? `${date.getHours()}` : `0${date.getHours()}`;
const minutes =
date.getMinutes() > 9 ? `${date.getMinutes()}` : `0${date.getMinutes()}`;
this.queueFaxTime = `${hours}:${minutes}`;
return this;
}
build(): QueueFaxRequest {

@@ -171,0 +196,0 @@ if (

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet