Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

email-octopus-ts

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

email-octopus-ts - npm Package Compare versions

Comparing version 1.0.0 to 1.1.1

CHANGELOG.md

13

dist/emailOctopus.d.ts

@@ -10,2 +10,15 @@ import { ApiKeyInvalidError } from "./errors/ApiKeyInvalidError";

lists: {
getList: (props: {
listId: string;
}) => Promise<import("./lists/types").List>;
getAllLists: (props: {
limit?: number | undefined;
page?: number | undefined;
}) => Promise<{
data: import("./lists/types").List[];
paging: import("./lists/types").Paging;
}>;
createList: (props: {
name: string;
}) => Promise<import("./lists/types").List>;
getAllContacts: (props: {

@@ -12,0 +25,0 @@ listId: string;

2

dist/emailOctopus.modern.js

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

import e from"axios";class s extends Error{constructor(e){super(e||"Your API key is invalid."),this.code="API_KEY_INVALID",this.message="Your API key is invalid.",this.message=e||"Your API key is invalid.",this.name="ApiKeyInvalidError"}}class t extends Error{constructor(e){super(e||"Generic email octopus error"),this.code="EMAIL_OCTOPUS_ERROR",this.message="Generic email octopus error",this.message=e||"Generic email octopus error",this.name="EmailOctopusError"}}class r extends Error{constructor(e){super(e||"Parameters are missing or invalid."),this.code="INVALID_PARAMETERS",this.message="Parameters are missing or invalid.",this.message=e||"Parameters are missing or invalid.",this.name="InvalidParametersError"}}class a extends Error{constructor(e){super(e||"A contact already exists with the supplied email address."),this.code="MEMBER_EXISTS_WITH_EMAIL_ADDRESS",this.message="A contact already exists with the supplied email address.",this.message=e||"A contact already exists with the supplied email address.",this.name="MemberExistsWithEmailAddressError"}}class i extends Error{constructor(e){super(e||"The requested endpoint does not exist."),this.code="NOT_FOUND",this.message="The requested endpoint does not exist.",this.message=e||"The requested endpoint does not exist.",this.name="NotFoundError"}}class o extends Error{constructor(e){super(e||"You're not authorised to perform that action."),this.code="UNAUTHORISED",this.message="You're not authorised to perform that action.",this.message=e||"You're not authorised to perform that action.",this.name="UnauthorisedError"}}function n(){return n=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},n.apply(this,arguments)}const c=(e,t)=>{if("INVALID_PARAMETERS"===e.code)throw new r(t.message);if("API_KEY_INVALID"===e.code)throw new s(t.message);if("UNAUTHORISED"===e.code)throw new o(t.message);if("NOT_FOUND"===e.code)throw new i(t.message)},d=s=>async r=>{try{return(await e.post(`https://emailoctopus.com/api/1.6/lists/${r.listId}/contacts`,n({api_key:s,email_address:r.emailAddress},r.fields&&{fields:r.fields},r.tags&&{tags:r.tags},r.status&&{status:r.status}))).data}catch(s){if(e.isAxiosError(s)&&s.response){var i;const e=null==(i=s.response)?void 0:i.data;if("MEMBER_EXISTS_WITH_EMAIL_ADDRESS"===e.code)throw new a;c(s,e)}throw new t}},l=s=>async(r,a)=>{let i=(null!=a&&a.autoPaginate?1:r.page)||1,o="next-initial",n=[];try{do{const t=await e.get(`https://emailoctopus.com/api/1.6/lists/${r.listId}/contacts`,{params:{api_key:s,limit:r.limit||100,page:i}});n.push(...t.data.data),null!=a&&a.autoPaginate?(i+=1,o=t.data.paging.next):o=null}while(null!==o)}catch(s){if(e.isAxiosError(s)&&s.response){var d;const e=null==(d=s.response)?void 0:d.data;c(s,e)}throw new t}return n},h=e=>({lists:{getAllContacts:l(e),createContact:d(e)}});export{s as ApiKeyInvalidError,t as EmailOctopusError,r as InvalidParametersError,a as MemberExistsWithEmailAddressError,i as NotFoundError,o as UnauthorisedError,h as emailOctopus};
import s from"axios";class e extends Error{constructor(s){super(s||"Your API key is invalid."),this.code="API_KEY_INVALID",this.message="Your API key is invalid.",this.message=s||"Your API key is invalid.",this.name="ApiKeyInvalidError"}}class t extends Error{constructor(s){super(s||"Generic email octopus error"),this.code="EMAIL_OCTOPUS_ERROR",this.message="Generic email octopus error",this.message=s||"Generic email octopus error",this.name="EmailOctopusError"}}class r extends Error{constructor(s){super(s||"Parameters are missing or invalid."),this.code="INVALID_PARAMETERS",this.message="Parameters are missing or invalid.",this.message=s||"Parameters are missing or invalid.",this.name="InvalidParametersError"}}class a extends Error{constructor(s){super(s||"A contact already exists with the supplied email address."),this.code="MEMBER_EXISTS_WITH_EMAIL_ADDRESS",this.message="A contact already exists with the supplied email address.",this.message=s||"A contact already exists with the supplied email address.",this.name="MemberExistsWithEmailAddressError"}}class o extends Error{constructor(s){super(s||"The requested endpoint does not exist."),this.code="NOT_FOUND",this.message="The requested endpoint does not exist.",this.message=s||"The requested endpoint does not exist.",this.name="NotFoundError"}}class i extends Error{constructor(s){super(s||"You're not authorised to perform that action."),this.code="UNAUTHORISED",this.message="You're not authorised to perform that action.",this.message=s||"You're not authorised to perform that action.",this.name="UnauthorisedError"}}function n(){return n=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r])}return s},n.apply(this,arguments)}class c extends Error{constructor(s){super(s||"An unknown error has occurred."),this.code="UNKNOWN",this.message="An unknown error has occurred.",this.message=s||"An unknown error has occurred.",this.name="UnknownError"}}const d=(s,t)=>{if("INVALID_PARAMETERS"===s.code)throw new r(t.message);if("API_KEY_INVALID"===s.code)throw new e(t.message);if("UNAUTHORISED"===s.code)throw new i(t.message);if("NOT_FOUND"===s.code)throw new o(t.message);if("UNKNOWN"===s.code)throw new c(t.message)},l=e=>async r=>{try{return(await s.post(`https://emailoctopus.com/api/1.6/lists/${r.listId}/contacts`,n({api_key:e,email_address:r.emailAddress},r.fields&&{fields:r.fields},r.tags&&{tags:r.tags},r.status&&{status:r.status}))).data}catch(e){if(s.isAxiosError(e)&&e.response){var o;const s=null==(o=e.response)?void 0:o.data;if("MEMBER_EXISTS_WITH_EMAIL_ADDRESS"===s.code)throw new a;d(e,s)}throw new t}},h=e=>async r=>{try{return(await s.post("https://emailoctopus.com/api/1.6/lists",{api_key:e,name:r.name})).data}catch(e){if(s.isAxiosError(e)&&e.response){var a;const s=null==(a=e.response)?void 0:a.data;d(e,s)}throw new t}},u=e=>async(r,a)=>{let o=(null!=a&&a.autoPaginate?1:r.page)||1,i="next-initial",n=[];try{do{const t=await s.get(`https://emailoctopus.com/api/1.6/lists/${r.listId}/contacts`,{params:{api_key:e,limit:r.limit||100,page:o}});n.push(...t.data.data),null!=a&&a.autoPaginate?(o+=1,i=t.data.paging.next):i=null}while(null!==i)}catch(e){if(s.isAxiosError(e)&&e.response){var c;const s=null==(c=e.response)?void 0:c.data;d(e,s)}throw new t}return n},p=e=>async r=>{try{return(await s.get("https://emailoctopus.com/api/1.6/lists",{params:{api_key:e,limit:r.limit||100,page:r.page||1}})).data}catch(e){if(s.isAxiosError(e)&&e.response){var a;const s=null==(a=e.response)?void 0:a.data;d(e,s)}throw new t}};class m extends Error{constructor(s){super(s||"The list could not be found."),this.code="LIST_NOT_FOUND",this.message="The list could not be found.",this.message=s||"The list could not be found.",this.name="ListNotFoundError"}}const g=e=>async r=>{try{return(await s.get(`https://emailoctopus.com/api/1.6/lists/${r.listId}`,{params:{api_key:e}})).data}catch(e){if(s.isAxiosError(e)&&e.response){var a;const s=null==(a=e.response)?void 0:a.data;if("LIST_NOT_FOUND"===s.code)throw new m;d(e,s)}throw new t}},E=s=>({lists:{getList:g(s),getAllLists:p(s),createList:h(s),getAllContacts:u(s),createContact:l(s)}});export{e as ApiKeyInvalidError,t as EmailOctopusError,r as InvalidParametersError,a as MemberExistsWithEmailAddressError,o as NotFoundError,i as UnauthorisedError,E as emailOctopus};
//# sourceMappingURL=emailOctopus.modern.js.map

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

import t from"axios";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},e.apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function s(t,e,r){return s=i()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&o(i,r.prototype),i},s.apply(null,arguments)}function a(t){var e="function"==typeof Map?new Map:void 0;return a=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return s(t,arguments,n(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o(r,t)},a(t)}var u=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Your API key is invalid.")||this).code="API_KEY_INVALID",r.message="Your API key is invalid.",r.message=e||"Your API key is invalid.",r.name="ApiKeyInvalidError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),c=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Generic email octopus error")||this).code="EMAIL_OCTOPUS_ERROR",r.message="Generic email octopus error",r.message=e||"Generic email octopus error",r.name="EmailOctopusError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),f=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Parameters are missing or invalid.")||this).code="INVALID_PARAMETERS",r.message="Parameters are missing or invalid.",r.message=e||"Parameters are missing or invalid.",r.name="InvalidParametersError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),l=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"A contact already exists with the supplied email address.")||this).code="MEMBER_EXISTS_WITH_EMAIL_ADDRESS",r.message="A contact already exists with the supplied email address.",r.message=e||"A contact already exists with the supplied email address.",r.name="MemberExistsWithEmailAddressError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),d=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"The requested endpoint does not exist.")||this).code="NOT_FOUND",r.message="The requested endpoint does not exist.",r.message=e||"The requested endpoint does not exist.",r.name="NotFoundError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),h=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"You're not authorised to perform that action.")||this).code="UNAUTHORISED",r.message="You're not authorised to perform that action.",r.message=e||"You're not authorised to perform that action.",r.name="UnauthorisedError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),p=function(t,e){if("INVALID_PARAMETERS"===t.code)throw new f(e.message);if("API_KEY_INVALID"===t.code)throw new u(e.message);if("UNAUTHORISED"===t.code)throw new h(e.message);if("NOT_FOUND"===t.code)throw new d(e.message)},v=function(r){return function(n){try{return Promise.resolve(function(o,i){try{var s=Promise.resolve(t.post("https://emailoctopus.com/api/1.6/lists/"+n.listId+"/contacts",e({api_key:r,email_address:n.emailAddress},n.fields&&{fields:n.fields},n.tags&&{tags:n.tags},n.status&&{status:n.status}))).then(function(t){return t.data})}catch(t){return i(t)}return s&&s.then?s.then(void 0,i):s}(0,function(e){if(t.isAxiosError(e)&&e.response){var r,n=null==(r=e.response)?void 0:r.data;if("MEMBER_EXISTS_WITH_EMAIL_ADDRESS"===n.code)throw new l;p(e,n)}throw new c}))}catch(t){return Promise.reject(t)}}};function m(t,e,r){if(!t.s){if(r instanceof y){if(!r.s)return void(r.o=m.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(m.bind(null,t,e),m.bind(null,t,2));t.s=e,t.v=r;const n=t.o;n&&n(t)}}var y=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,r){var n=new t,o=this.s;if(o){var i=1&o?e:r;if(i){try{m(n,1,i(this.v))}catch(t){m(n,2,t)}return n}return this}return this.o=function(t){try{var o=t.v;1&t.s?m(n,1,e?e(o):o):r?m(n,1,r(o)):m(n,2,o)}catch(t){m(n,2,t)}},n},t}();function g(t){return t instanceof y&&1&t.s}var E=function(e){return function(r,n){try{var o=(null!=n&&n.autoPaginate?1:r.page)||1,i="next-initial",s=[],a=function(a,u){try{var c=function(){var a=function(t,e){var r;do{var n=t();if(n&&n.then){if(!g(n)){r=!0;break}n=n.v}var o=e();if(g(o)&&(o=o.v),!o)return n}while(!o.then);var i=new y,s=m.bind(null,i,2);return(r?n.then(a):o.then(u)).then(void 0,s),i;function a(r){for(n=r;g(o=e())&&(o=o.v),o;){if(o.then)return void o.then(u).then(void 0,s);if((n=t())&&n.then){if(!g(n))return void n.then(a).then(void 0,s);n=n.v}}m(i,1,n)}function u(r){if(r){do{if((n=t())&&n.then){if(!g(n))return void n.then(a).then(void 0,s);n=n.v}if(g(r=e())&&(r=r.v),!r)return void m(i,1,n)}while(!r.then);r.then(u).then(void 0,s)}else m(i,1,n)}}(function(){return Promise.resolve(t.get("https://emailoctopus.com/api/1.6/lists/"+r.listId+"/contacts",{params:{api_key:e,limit:r.limit||100,page:o}})).then(function(t){s.push.apply(s,t.data.data),null!=n&&n.autoPaginate?(o+=1,i=t.data.paging.next):i=null})},function(){return null!==i});if(a&&a.then)return a.then(function(){})}()}catch(t){return u(t)}return c&&c.then?c.then(void 0,u):c}(0,function(e){if(t.isAxiosError(e)&&e.response){var r,n=null==(r=e.response)?void 0:r.data;p(e,n)}throw new c});return Promise.resolve(a&&a.then?a.then(function(t){return s}):s)}catch(t){return Promise.reject(t)}}},A=function(t){return{lists:{getAllContacts:E(t),createContact:v(t)}}};export{u as ApiKeyInvalidError,c as EmailOctopusError,f as InvalidParametersError,l as MemberExistsWithEmailAddressError,d as NotFoundError,h as UnauthorisedError,A as emailOctopus};
import t from"axios";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},e.apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function s(t,e,r){return s=i()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&o(i,r.prototype),i},s.apply(null,arguments)}function a(t){var e="function"==typeof Map?new Map:void 0;return a=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return s(t,arguments,n(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o(r,t)},a(t)}var u=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Your API key is invalid.")||this).code="API_KEY_INVALID",r.message="Your API key is invalid.",r.message=e||"Your API key is invalid.",r.name="ApiKeyInvalidError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),c=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Generic email octopus error")||this).code="EMAIL_OCTOPUS_ERROR",r.message="Generic email octopus error",r.message=e||"Generic email octopus error",r.name="EmailOctopusError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),f=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Parameters are missing or invalid.")||this).code="INVALID_PARAMETERS",r.message="Parameters are missing or invalid.",r.message=e||"Parameters are missing or invalid.",r.name="InvalidParametersError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),l=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"A contact already exists with the supplied email address.")||this).code="MEMBER_EXISTS_WITH_EMAIL_ADDRESS",r.message="A contact already exists with the supplied email address.",r.message=e||"A contact already exists with the supplied email address.",r.name="MemberExistsWithEmailAddressError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),h=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"The requested endpoint does not exist.")||this).code="NOT_FOUND",r.message="The requested endpoint does not exist.",r.message=e||"The requested endpoint does not exist.",r.name="NotFoundError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),d=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"You're not authorised to perform that action.")||this).code="UNAUTHORISED",r.message="You're not authorised to perform that action.",r.message=e||"You're not authorised to perform that action.",r.name="UnauthorisedError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),p=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"An unknown error has occurred.")||this).code="UNKNOWN",r.message="An unknown error has occurred.",r.message=e||"An unknown error has occurred.",r.name="UnknownError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),v=function(t,e){if("INVALID_PARAMETERS"===t.code)throw new f(e.message);if("API_KEY_INVALID"===t.code)throw new u(e.message);if("UNAUTHORISED"===t.code)throw new d(e.message);if("NOT_FOUND"===t.code)throw new h(e.message);if("UNKNOWN"===t.code)throw new p(e.message)},m=function(r){return function(n){try{return Promise.resolve(function(o,i){try{var s=Promise.resolve(t.post("https://emailoctopus.com/api/1.6/lists/"+n.listId+"/contacts",e({api_key:r,email_address:n.emailAddress},n.fields&&{fields:n.fields},n.tags&&{tags:n.tags},n.status&&{status:n.status}))).then(function(t){return t.data})}catch(t){return i(t)}return s&&s.then?s.then(void 0,i):s}(0,function(e){if(t.isAxiosError(e)&&e.response){var r,n=null==(r=e.response)?void 0:r.data;if("MEMBER_EXISTS_WITH_EMAIL_ADDRESS"===n.code)throw new l;v(e,n)}throw new c}))}catch(t){return Promise.reject(t)}}},y=function(e){return function(r){try{return Promise.resolve(function(n,o){try{var i=Promise.resolve(t.post("https://emailoctopus.com/api/1.6/lists",{api_key:e,name:r.name})).then(function(t){return t.data})}catch(t){return o(t)}return i&&i.then?i.then(void 0,o):i}(0,function(e){if(t.isAxiosError(e)&&e.response){var r,n=null==(r=e.response)?void 0:r.data;v(e,n)}throw new c}))}catch(t){return Promise.reject(t)}}};function g(t,e,r){if(!t.s){if(r instanceof E){if(!r.s)return void(r.o=g.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(g.bind(null,t,e),g.bind(null,t,2));t.s=e,t.v=r;const n=t.o;n&&n(t)}}var E=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,r){var n=new t,o=this.s;if(o){var i=1&o?e:r;if(i){try{g(n,1,i(this.v))}catch(t){g(n,2,t)}return n}return this}return this.o=function(t){try{var o=t.v;1&t.s?g(n,1,e?e(o):o):r?g(n,1,r(o)):g(n,2,o)}catch(t){g(n,2,t)}},n},t}();function w(t){return t instanceof E&&1&t.s}var A=function(e){return function(r,n){try{var o=(null!=n&&n.autoPaginate?1:r.page)||1,i="next-initial",s=[],a=function(a,u){try{var c=function(){var a=function(t,e){var r;do{var n=t();if(n&&n.then){if(!w(n)){r=!0;break}n=n.v}var o=e();if(w(o)&&(o=o.v),!o)return n}while(!o.then);var i=new E,s=g.bind(null,i,2);return(r?n.then(a):o.then(u)).then(void 0,s),i;function a(r){for(n=r;w(o=e())&&(o=o.v),o;){if(o.then)return void o.then(u).then(void 0,s);if((n=t())&&n.then){if(!w(n))return void n.then(a).then(void 0,s);n=n.v}}g(i,1,n)}function u(r){if(r){do{if((n=t())&&n.then){if(!w(n))return void n.then(a).then(void 0,s);n=n.v}if(w(r=e())&&(r=r.v),!r)return void g(i,1,n)}while(!r.then);r.then(u).then(void 0,s)}else g(i,1,n)}}(function(){return Promise.resolve(t.get("https://emailoctopus.com/api/1.6/lists/"+r.listId+"/contacts",{params:{api_key:e,limit:r.limit||100,page:o}})).then(function(t){s.push.apply(s,t.data.data),null!=n&&n.autoPaginate?(o+=1,i=t.data.paging.next):i=null})},function(){return null!==i});if(a&&a.then)return a.then(function(){})}()}catch(t){return u(t)}return c&&c.then?c.then(void 0,u):c}(0,function(e){if(t.isAxiosError(e)&&e.response){var r,n=null==(r=e.response)?void 0:r.data;v(e,n)}throw new c});return Promise.resolve(a&&a.then?a.then(function(t){return s}):s)}catch(t){return Promise.reject(t)}}},P=function(e){return function(r){try{return Promise.resolve(function(n,o){try{var i=Promise.resolve(t.get("https://emailoctopus.com/api/1.6/lists",{params:{api_key:e,limit:r.limit||100,page:r.page||1}})).then(function(t){return t.data})}catch(t){return o(t)}return i&&i.then?i.then(void 0,o):i}(0,function(e){if(t.isAxiosError(e)&&e.response){var r,n=null==(r=e.response)?void 0:r.data;v(e,n)}throw new c}))}catch(t){return Promise.reject(t)}}},_=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"The list could not be found.")||this).code="LIST_NOT_FOUND",r.message="The list could not be found.",r.message=e||"The list could not be found.",r.name="ListNotFoundError",r}return r(e,t),e}(/*#__PURE__*/a(Error)),O=function(e){return function(r){try{return Promise.resolve(function(n,o){try{var i=Promise.resolve(t.get("https://emailoctopus.com/api/1.6/lists/"+r.listId,{params:{api_key:e}})).then(function(t){return t.data})}catch(t){return o(t)}return i&&i.then?i.then(void 0,o):i}(0,function(e){if(t.isAxiosError(e)&&e.response){var r,n=null==(r=e.response)?void 0:r.data;if("LIST_NOT_FOUND"===n.code)throw new _;v(e,n)}throw new c}))}catch(t){return Promise.reject(t)}}},I=function(t){return{lists:{getList:O(t),getAllLists:P(t),createList:y(t),getAllContacts:A(t),createContact:m(t)}}};export{u as ApiKeyInvalidError,c as EmailOctopusError,f as InvalidParametersError,l as MemberExistsWithEmailAddressError,h as NotFoundError,d as UnauthorisedError,I as emailOctopus};
//# sourceMappingURL=emailOctopus.module.js.map

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],e):e((t||self).emailOctopusTs={},t.axios)}(this,function(t,e){function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=/*#__PURE__*/r(e);function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o.apply(this,arguments)}function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,a(t,e)}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function c(t,e,r){return c=u()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&a(o,r.prototype),o},c.apply(null,arguments)}function f(t){var e="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return c(t,arguments,s(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,t)},f(t)}var l=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Your API key is invalid.")||this).code="API_KEY_INVALID",r.message="Your API key is invalid.",r.message=e||"Your API key is invalid.",r.name="ApiKeyInvalidError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),d=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Generic email octopus error")||this).code="EMAIL_OCTOPUS_ERROR",r.message="Generic email octopus error",r.message=e||"Generic email octopus error",r.name="EmailOctopusError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),h=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Parameters are missing or invalid.")||this).code="INVALID_PARAMETERS",r.message="Parameters are missing or invalid.",r.message=e||"Parameters are missing or invalid.",r.name="InvalidParametersError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),p=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"A contact already exists with the supplied email address.")||this).code="MEMBER_EXISTS_WITH_EMAIL_ADDRESS",r.message="A contact already exists with the supplied email address.",r.message=e||"A contact already exists with the supplied email address.",r.name="MemberExistsWithEmailAddressError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),v=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"The requested endpoint does not exist.")||this).code="NOT_FOUND",r.message="The requested endpoint does not exist.",r.message=e||"The requested endpoint does not exist.",r.name="NotFoundError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),m=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"You're not authorised to perform that action.")||this).code="UNAUTHORISED",r.message="You're not authorised to perform that action.",r.message=e||"You're not authorised to perform that action.",r.name="UnauthorisedError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),y=function(t,e){if("INVALID_PARAMETERS"===t.code)throw new h(e.message);if("API_KEY_INVALID"===t.code)throw new l(e.message);if("UNAUTHORISED"===t.code)throw new m(e.message);if("NOT_FOUND"===t.code)throw new v(e.message)},E=function(t){return function(e){try{return Promise.resolve(function(r,i){try{var s=Promise.resolve(n.default.post("https://emailoctopus.com/api/1.6/lists/"+e.listId+"/contacts",o({api_key:t,email_address:e.emailAddress},e.fields&&{fields:e.fields},e.tags&&{tags:e.tags},e.status&&{status:e.status}))).then(function(t){return t.data})}catch(t){return i(t)}return s&&s.then?s.then(void 0,i):s}(0,function(t){if(n.default.isAxiosError(t)&&t.response){var e,r=null==(e=t.response)?void 0:e.data;if("MEMBER_EXISTS_WITH_EMAIL_ADDRESS"===r.code)throw new p;y(t,r)}throw new d}))}catch(t){return Promise.reject(t)}}};function g(t,e,r){if(!t.s){if(r instanceof A){if(!r.s)return void(r.o=g.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(g.bind(null,t,e),g.bind(null,t,2));t.s=e,t.v=r;const n=t.o;n&&n(t)}}var A=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,r){var n=new t,o=this.s;if(o){var i=1&o?e:r;if(i){try{g(n,1,i(this.v))}catch(t){g(n,2,t)}return n}return this}return this.o=function(t){try{var o=t.v;1&t.s?g(n,1,e?e(o):o):r?g(n,1,r(o)):g(n,2,o)}catch(t){g(n,2,t)}},n},t}();function O(t){return t instanceof A&&1&t.s}var b=function(t){return function(e,r){try{var o=(null!=r&&r.autoPaginate?1:e.page)||1,i="next-initial",s=[],a=function(a,u){try{var c=function(){var a=function(t,e){var r;do{var n=t();if(n&&n.then){if(!O(n)){r=!0;break}n=n.v}var o=e();if(O(o)&&(o=o.v),!o)return n}while(!o.then);var i=new A,s=g.bind(null,i,2);return(r?n.then(a):o.then(u)).then(void 0,s),i;function a(r){for(n=r;O(o=e())&&(o=o.v),o;){if(o.then)return void o.then(u).then(void 0,s);if((n=t())&&n.then){if(!O(n))return void n.then(a).then(void 0,s);n=n.v}}g(i,1,n)}function u(r){if(r){do{if((n=t())&&n.then){if(!O(n))return void n.then(a).then(void 0,s);n=n.v}if(O(r=e())&&(r=r.v),!r)return void g(i,1,n)}while(!r.then);r.then(u).then(void 0,s)}else g(i,1,n)}}(function(){return Promise.resolve(n.default.get("https://emailoctopus.com/api/1.6/lists/"+e.listId+"/contacts",{params:{api_key:t,limit:e.limit||100,page:o}})).then(function(t){s.push.apply(s,t.data.data),null!=r&&r.autoPaginate?(o+=1,i=t.data.paging.next):i=null})},function(){return null!==i});if(a&&a.then)return a.then(function(){})}()}catch(t){return u(t)}return c&&c.then?c.then(void 0,u):c}(0,function(t){if(n.default.isAxiosError(t)&&t.response){var e,r=null==(e=t.response)?void 0:e.data;y(t,r)}throw new d});return Promise.resolve(a&&a.then?a.then(function(t){return s}):s)}catch(t){return Promise.reject(t)}}};t.ApiKeyInvalidError=l,t.EmailOctopusError=d,t.InvalidParametersError=h,t.MemberExistsWithEmailAddressError=p,t.NotFoundError=v,t.UnauthorisedError=m,t.emailOctopus=function(t){return{lists:{getAllContacts:b(t),createContact:E(t)}}}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],e):e((t||self).emailOctopusTs={},t.axios)}(this,function(t,e){function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=/*#__PURE__*/r(e);function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o.apply(this,arguments)}function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,a(t,e)}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function c(t,e,r){return c=u()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&a(o,r.prototype),o},c.apply(null,arguments)}function f(t){var e="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return c(t,arguments,s(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,t)},f(t)}var l=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Your API key is invalid.")||this).code="API_KEY_INVALID",r.message="Your API key is invalid.",r.message=e||"Your API key is invalid.",r.name="ApiKeyInvalidError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),d=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Generic email octopus error")||this).code="EMAIL_OCTOPUS_ERROR",r.message="Generic email octopus error",r.message=e||"Generic email octopus error",r.name="EmailOctopusError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),h=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"Parameters are missing or invalid.")||this).code="INVALID_PARAMETERS",r.message="Parameters are missing or invalid.",r.message=e||"Parameters are missing or invalid.",r.name="InvalidParametersError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),p=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"A contact already exists with the supplied email address.")||this).code="MEMBER_EXISTS_WITH_EMAIL_ADDRESS",r.message="A contact already exists with the supplied email address.",r.message=e||"A contact already exists with the supplied email address.",r.name="MemberExistsWithEmailAddressError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),m=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"The requested endpoint does not exist.")||this).code="NOT_FOUND",r.message="The requested endpoint does not exist.",r.message=e||"The requested endpoint does not exist.",r.name="NotFoundError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),v=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"You're not authorised to perform that action.")||this).code="UNAUTHORISED",r.message="You're not authorised to perform that action.",r.message=e||"You're not authorised to perform that action.",r.name="UnauthorisedError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),y=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"An unknown error has occurred.")||this).code="UNKNOWN",r.message="An unknown error has occurred.",r.message=e||"An unknown error has occurred.",r.name="UnknownError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),E=function(t,e){if("INVALID_PARAMETERS"===t.code)throw new h(e.message);if("API_KEY_INVALID"===t.code)throw new l(e.message);if("UNAUTHORISED"===t.code)throw new v(e.message);if("NOT_FOUND"===t.code)throw new m(e.message);if("UNKNOWN"===t.code)throw new y(e.message)},g=function(t){return function(e){try{return Promise.resolve(function(r,i){try{var s=Promise.resolve(n.default.post("https://emailoctopus.com/api/1.6/lists/"+e.listId+"/contacts",o({api_key:t,email_address:e.emailAddress},e.fields&&{fields:e.fields},e.tags&&{tags:e.tags},e.status&&{status:e.status}))).then(function(t){return t.data})}catch(t){return i(t)}return s&&s.then?s.then(void 0,i):s}(0,function(t){if(n.default.isAxiosError(t)&&t.response){var e,r=null==(e=t.response)?void 0:e.data;if("MEMBER_EXISTS_WITH_EMAIL_ADDRESS"===r.code)throw new p;E(t,r)}throw new d}))}catch(t){return Promise.reject(t)}}},w=function(t){return function(e){try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(n.default.post("https://emailoctopus.com/api/1.6/lists",{api_key:t,name:e.name})).then(function(t){return t.data})}catch(t){return o(t)}return i&&i.then?i.then(void 0,o):i}(0,function(t){if(n.default.isAxiosError(t)&&t.response){var e,r=null==(e=t.response)?void 0:e.data;E(t,r)}throw new d}))}catch(t){return Promise.reject(t)}}};function A(t,e,r){if(!t.s){if(r instanceof O){if(!r.s)return void(r.o=A.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(A.bind(null,t,e),A.bind(null,t,2));t.s=e,t.v=r;const n=t.o;n&&n(t)}}var O=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,r){var n=new t,o=this.s;if(o){var i=1&o?e:r;if(i){try{A(n,1,i(this.v))}catch(t){A(n,2,t)}return n}return this}return this.o=function(t){try{var o=t.v;1&t.s?A(n,1,e?e(o):o):r?A(n,1,r(o)):A(n,2,o)}catch(t){A(n,2,t)}},n},t}();function P(t){return t instanceof O&&1&t.s}var _=function(t){return function(e,r){try{var o=(null!=r&&r.autoPaginate?1:e.page)||1,i="next-initial",s=[],a=function(a,u){try{var c=function(){var a=function(t,e){var r;do{var n=t();if(n&&n.then){if(!P(n)){r=!0;break}n=n.v}var o=e();if(P(o)&&(o=o.v),!o)return n}while(!o.then);var i=new O,s=A.bind(null,i,2);return(r?n.then(a):o.then(u)).then(void 0,s),i;function a(r){for(n=r;P(o=e())&&(o=o.v),o;){if(o.then)return void o.then(u).then(void 0,s);if((n=t())&&n.then){if(!P(n))return void n.then(a).then(void 0,s);n=n.v}}A(i,1,n)}function u(r){if(r){do{if((n=t())&&n.then){if(!P(n))return void n.then(a).then(void 0,s);n=n.v}if(P(r=e())&&(r=r.v),!r)return void A(i,1,n)}while(!r.then);r.then(u).then(void 0,s)}else A(i,1,n)}}(function(){return Promise.resolve(n.default.get("https://emailoctopus.com/api/1.6/lists/"+e.listId+"/contacts",{params:{api_key:t,limit:e.limit||100,page:o}})).then(function(t){s.push.apply(s,t.data.data),null!=r&&r.autoPaginate?(o+=1,i=t.data.paging.next):i=null})},function(){return null!==i});if(a&&a.then)return a.then(function(){})}()}catch(t){return u(t)}return c&&c.then?c.then(void 0,u):c}(0,function(t){if(n.default.isAxiosError(t)&&t.response){var e,r=null==(e=t.response)?void 0:e.data;E(t,r)}throw new d});return Promise.resolve(a&&a.then?a.then(function(t){return s}):s)}catch(t){return Promise.reject(t)}}},b=function(t){return function(e){try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(n.default.get("https://emailoctopus.com/api/1.6/lists",{params:{api_key:t,limit:e.limit||100,page:e.page||1}})).then(function(t){return t.data})}catch(t){return o(t)}return i&&i.then?i.then(void 0,o):i}(0,function(t){if(n.default.isAxiosError(t)&&t.response){var e,r=null==(e=t.response)?void 0:e.data;E(t,r)}throw new d}))}catch(t){return Promise.reject(t)}}},I=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e||"The list could not be found.")||this).code="LIST_NOT_FOUND",r.message="The list could not be found.",r.message=e||"The list could not be found.",r.name="ListNotFoundError",r}return i(e,t),e}(/*#__PURE__*/f(Error)),T=function(t){return function(e){try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(n.default.get("https://emailoctopus.com/api/1.6/lists/"+e.listId,{params:{api_key:t}})).then(function(t){return t.data})}catch(t){return o(t)}return i&&i.then?i.then(void 0,o):i}(0,function(t){if(n.default.isAxiosError(t)&&t.response){var e,r=null==(e=t.response)?void 0:e.data;if("LIST_NOT_FOUND"===r.code)throw new I;E(t,r)}throw new d}))}catch(t){return Promise.reject(t)}}};t.ApiKeyInvalidError=l,t.EmailOctopusError=d,t.InvalidParametersError=h,t.MemberExistsWithEmailAddressError=p,t.NotFoundError=m,t.UnauthorisedError=v,t.emailOctopus=function(t){return{lists:{getList:T(t),getAllLists:b(t),createList:w(t),getAllContacts:_(t),createContact:g(t)}}}});
//# sourceMappingURL=emailOctopus.umd.js.map

@@ -8,3 +8,3 @@ {

],
"version": "1.0.0",
"version": "1.1.1",
"type": "module",

@@ -21,2 +21,3 @@ "source": "src/emailOctopus.ts",

"scripts": {
"format:all": "prettier --write .",
"build": "microbundle",

@@ -27,10 +28,10 @@ "dev": "microbundle watch",

"devDependencies": {
"@types/jest": "^28.1.1",
"husky": "^8.0.1",
"lint-staged": "^13.0.1",
"microbundle": "^0.15.0",
"prettier": "^2.6.2"
"@types/jest": "^29.5.4",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"microbundle": "^0.15.1",
"prettier": "^3.0.3"
},
"dependencies": {
"axios": "^0.27.2"
"axios": "^1.5.0"
},

@@ -37,0 +38,0 @@ "lint-staged": {

@@ -8,3 +8,6 @@ import { ApiKeyInvalidError } from "./errors/ApiKeyInvalidError";

import { createContact } from "./lists/createContact";
import { createList } from "./lists/createList";
import { getAllContacts } from "./lists/getAllContacts";
import { getAllLists } from "./lists/getAllLists";
import { getList } from "./lists/getList";

@@ -23,2 +26,5 @@ export {

lists: {
getList: getList(apiKey),
getAllLists: getAllLists(apiKey),
createList: createList(apiKey),
getAllContacts: getAllContacts(apiKey),

@@ -25,0 +31,0 @@ createContact: createContact(apiKey),

@@ -6,2 +6,3 @@ import { AxiosError } from "axios";

import { UnauthorisedError } from "src/errors/UnauthorisedError";
import { UnknownError } from "src/errors/UnknownError";
import { ApiWideErrorResponses } from "src/types";

@@ -25,2 +26,5 @@

}
if (error.code === "UNKNOWN") {
throw new UnknownError(errorData.message);
}
};

@@ -5,2 +5,3 @@ import axios from "axios";

import { EmailOctopusError } from "../errors/EmailOctopusError";
import { Paging } from "./types";

@@ -19,6 +20,3 @@ type GetAllContactsProps = {

data: Array<Contact>;
paging: {
previous: null | string;
next: null | string;
};
paging: Paging;
};

@@ -25,0 +23,0 @@

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc