mailgun.js
Advanced tools
Comparing version 3.6.1 to 3.7.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [3.7.0](https://github.com/mailgun/mailgun-js/compare/v3.6.1...v3.7.0) (2021-10-20) | ||
### Features | ||
* Fix linter errors ([126ba03](https://github.com/mailgun/mailgun-js/commits/126ba039bccfbdb257ddde7d17a58790e4cd30a3)) | ||
### [3.6.1](https://github.com/mailgun/mailgun-js/compare/v3.6.0...v3.6.1) (2021-10-18) | ||
@@ -7,0 +14,0 @@ |
@@ -6,5 +6,5 @@ import Client from './lib/client'; | ||
private formData; | ||
constructor(FormData: new (...args: any[]) => IFormData); | ||
constructor(FormData: new (...args: unknown[]) => IFormData); | ||
client(options: Options): Client; | ||
} | ||
export = Mailgun; |
@@ -31,3 +31,3 @@ import Request from './request'; | ||
lists: ListsClient; | ||
constructor(options: Options, formData: new (...args: any[]) => IFormData); | ||
constructor(options: Options, formData: new (...args: unknown[]) => IFormData); | ||
} |
@@ -1,29 +0,13 @@ | ||
declare const MgRequest: any; | ||
import { EventsList, EventsPage, EventsResponse, PagesList } from './interfaces/Events'; | ||
import Request from './request'; | ||
export default class EventClient { | ||
request: typeof MgRequest; | ||
constructor(request: typeof MgRequest); | ||
request: Request; | ||
constructor(request: Request); | ||
_parsePageNumber(url: string): string; | ||
_parsePage(id: string, url: string): { | ||
id: string; | ||
number: string; | ||
url: string; | ||
}; | ||
_parsePageLinks(response: { | ||
body: { | ||
paging: any; | ||
}; | ||
}): any; | ||
_parseEventList(response: { | ||
body: { | ||
items: any; | ||
paging: any; | ||
}; | ||
}): { | ||
items: any; | ||
pages: any; | ||
}; | ||
_parsePage(id: string, url: string): EventsPage; | ||
_parsePageLinks(response: EventsResponse): PagesList; | ||
_parseEventList(response: EventsResponse): EventsList; | ||
get(domain: string, query: { | ||
page: any; | ||
}): any; | ||
page: string; | ||
}): Promise<EventsList>; | ||
} | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
export default interface APIErrorOptions { | ||
interface APIErrorOptions { | ||
headers: { | ||
@@ -11,1 +11,2 @@ [key: string]: any; | ||
} | ||
export default APIErrorOptions; |
@@ -1,4 +0,5 @@ | ||
export default interface APIResponse { | ||
interface APIResponse { | ||
status: number; | ||
body: any; | ||
} | ||
export default APIResponse; |
@@ -8,1 +8,13 @@ export interface IpPool { | ||
} | ||
export interface IpPoolListResponse { | ||
body: { | ||
ip_pools: IpPool; | ||
message: string; | ||
}; | ||
} | ||
export interface IpPoolUpdateData { | ||
name: string; | ||
description: string; | ||
add_ip: string; | ||
remove_ip: string; | ||
} |
import { MailingList } from './lists'; | ||
export interface MailListMember { | ||
address: string; | ||
name: string; | ||
subscribed: boolean; | ||
vars: string | any; | ||
} | ||
export interface MailListMembersQuery { | ||
@@ -28,8 +34,2 @@ subscribed?: 'yes' | 'no'; | ||
} | ||
export interface MailListMember { | ||
address: string; | ||
name: string; | ||
subscribed: boolean; | ||
vars: string | any; | ||
} | ||
export interface DeletedMember { | ||
@@ -36,0 +36,0 @@ member: { |
@@ -1,2 +0,2 @@ | ||
export default interface Options { | ||
interface Options { | ||
username: string; | ||
@@ -8,1 +8,2 @@ key: string; | ||
} | ||
export default Options; |
import Options from './Options'; | ||
export default interface RequestOptions extends Options { | ||
interface RequestOptions extends Options { | ||
headers: any; | ||
timeout: number; | ||
} | ||
export default RequestOptions; |
@@ -1,2 +0,2 @@ | ||
export default interface StatsOptions { | ||
interface StatsOptions { | ||
start: string | Date; | ||
@@ -14,1 +14,2 @@ end: string | Date; | ||
} | ||
export default StatsOptions; |
@@ -1,7 +0,7 @@ | ||
declare const MgRequest: any; | ||
import { IpPool } from "./interfaces/IpPools"; | ||
import Request from './request'; | ||
import { IpPool, IpPoolUpdateData } from './interfaces/IpPools'; | ||
export default class IpPoolsClient { | ||
request: typeof MgRequest; | ||
constructor(request: typeof MgRequest); | ||
list(query: any): IpPool[]; | ||
request: Request; | ||
constructor(request: Request); | ||
list(query: any): Promise<IpPool[]>; | ||
create(data: { | ||
@@ -11,15 +11,12 @@ name: string; | ||
ips?: string[]; | ||
}): any; | ||
update(poolId: string, data: { | ||
name: string; | ||
description: string; | ||
add_ip: string; | ||
remove_ip: string; | ||
}): any; | ||
}): Promise<{ | ||
message: string; | ||
pool_id: string; | ||
}>; | ||
update(poolId: string, data: IpPoolUpdateData): Promise<any>; | ||
delete(poolId: string, data: { | ||
id: string; | ||
pool_id: string; | ||
}): any; | ||
}): Promise<any>; | ||
private parseIpPoolsResponse; | ||
} | ||
export {}; |
@@ -1,9 +0,9 @@ | ||
declare const MgRequest: any; | ||
import MgRequest from './request'; | ||
import { IpData, IpsListResponseBody } from './interfaces/Ips'; | ||
export default class IpsClient { | ||
request: typeof MgRequest; | ||
constructor(request: typeof MgRequest); | ||
list(query: any): any; | ||
get(ip: string): any; | ||
request: MgRequest; | ||
constructor(request: MgRequest); | ||
list(query: any): Promise<IpsListResponseBody | IpData>; | ||
get(ip: string): Promise<IpsListResponseBody | IpData>; | ||
private parseIpsResponse; | ||
} | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import Request from "./request"; | ||
import Request from './request'; | ||
export default class MessagesClient { | ||
@@ -3,0 +3,0 @@ request: Request; |
import Request from './request'; | ||
import { BounceData, ComplaintData, UnsubscribeData } from './interfaces/Supressions'; | ||
declare type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe; | ||
declare class Bounce { | ||
@@ -25,2 +24,3 @@ type: string; | ||
} | ||
declare type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe; | ||
export default class SuppressionClient { | ||
@@ -27,0 +27,0 @@ request: any; |
@@ -5,2 +5,2 @@ /*! MIT License © Sindre Sorhus */ | ||
/*! mailgun.js v3.6.0 */ | ||
/*! mailgun.js v3.6.1 */ |
@@ -7,2 +7,2 @@ /*! MIT License © Sindre Sorhus */ | ||
/*! mailgun.js v3.6.0 */ | ||
/*! mailgun.js v3.6.1 */ |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable no-console */ | ||
const mailgun = require('../index'); | ||
@@ -2,0 +3,0 @@ |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable no-console */ | ||
const mailgun = require('../index'); | ||
@@ -2,0 +3,0 @@ |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable no-console */ | ||
const fs = require('fs'); | ||
@@ -2,0 +3,0 @@ const mailgun = require('../index'); |
@@ -8,3 +8,3 @@ import Client from './lib/client'; | ||
constructor(FormData: new (...args: any[]) => IFormData) { | ||
constructor(FormData: new (...args: unknown[]) => IFormData) { | ||
this.formData = FormData; | ||
@@ -11,0 +11,0 @@ } |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable camelcase */ | ||
import Request from './request'; | ||
@@ -37,7 +38,7 @@ import Options from './interfaces/Options'; | ||
constructor(options: Options, formData: new (...args: any[]) => IFormData) { | ||
constructor(options: Options, formData: new (...args: unknown[]) => IFormData) { | ||
const config: RequestOptions = { ...options } as RequestOptions; | ||
if (!config.url) { | ||
config.url = 'https://api.mailgun.net' | ||
config.url = 'https://api.mailgun.net'; | ||
} | ||
@@ -44,0 +45,0 @@ |
@@ -1,24 +0,27 @@ | ||
const urljoin = require('url-join'); | ||
import urljoin from 'url-join'; | ||
import { | ||
EventsList, EventsPage, EventsResponse, PagesList, PagesListAccumulator | ||
} from './interfaces/Events'; | ||
const MgRequest = require('./request'); | ||
import Request from './request'; | ||
export default class EventClient { | ||
request: typeof MgRequest; | ||
request: Request; | ||
constructor(request: typeof MgRequest) { | ||
constructor(request: Request) { | ||
this.request = request; | ||
} | ||
_parsePageNumber(url: string) { | ||
_parsePageNumber(url: string) : string { | ||
return url.split('/').pop(); | ||
} | ||
_parsePage(id: string, url: string) { | ||
_parsePage(id: string, url: string) : EventsPage { | ||
return { id, number: this._parsePageNumber(url), url }; | ||
} | ||
_parsePageLinks(response: { body: { paging: any } }) { | ||
const pages = Object.entries(response.body.paging); | ||
_parsePageLinks(response: EventsResponse) : PagesList { | ||
const pages = Object.entries(response.body.paging as PagesList); | ||
return pages.reduce( | ||
(acc: any, entrie: [url: string, id: string]) => { | ||
(acc: PagesListAccumulator, entrie: [url: string, id: string]) => { | ||
const id = entrie[0]; | ||
@@ -29,6 +32,6 @@ const url = entrie[1]; | ||
}, {} | ||
); | ||
) as unknown as PagesList; | ||
} | ||
_parseEventList(response: { body: { items: any, paging: any } }) { | ||
_parseEventList(response: EventsResponse) : EventsList { | ||
return { | ||
@@ -40,15 +43,14 @@ items: response.body.items, | ||
get(domain: string, query: { page: any }) { | ||
get(domain: string, query: { page: string }) : Promise<EventsList> { | ||
let url; | ||
if (query && query.page) { | ||
url = urljoin('/v2', domain, 'events', query.page); | ||
delete query.page; | ||
const queryCopy = { ...query }; | ||
if (queryCopy && queryCopy.page) { | ||
url = urljoin('/v2', domain, 'events', queryCopy.page); | ||
delete queryCopy.page; | ||
} else { | ||
url = urljoin('/v2', domain, 'events'); | ||
} | ||
return this.request.get(url, query) | ||
.then((response: { body: { items: any, paging: any } }) => this._parseEventList(response)); | ||
return this.request.get(url, queryCopy) | ||
.then((response: EventsResponse) => this._parseEventList(response)); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
export default interface APIErrorOptions { | ||
interface APIErrorOptions { | ||
headers: { [key: string]: any }; | ||
@@ -9,1 +9,3 @@ status: number | string; | ||
} | ||
export default APIErrorOptions; |
@@ -1,4 +0,6 @@ | ||
export default interface APIResponse { | ||
interface APIResponse { | ||
status: number; | ||
body: any; | ||
} | ||
export default APIResponse; |
@@ -14,6 +14,7 @@ interface Headers { | ||
export default abstract class IFormData { | ||
constructor(){ //description of type. Should not be used for creating objects | ||
} | ||
// eslint-disable-next-line no-useless-constructor | ||
constructor() { // description of type. Should not be used for creating objects | ||
} | ||
abstract append(key: string, value: any, options?: AppendOptions | string): void | ||
abstract append(key: string, value: any, options?: AppendOptions | string): void | ||
} |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable camelcase */ | ||
export interface IpPool { | ||
@@ -7,2 +8,16 @@ description: string; | ||
pool_id: string; | ||
} | ||
} | ||
export interface IpPoolListResponse { | ||
body: { | ||
ip_pools: IpPool, | ||
message: string | ||
} | ||
} | ||
export interface IpPoolUpdateData { | ||
name: string, | ||
description: string, | ||
add_ip: string, | ||
remove_ip: string | ||
} |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable camelcase */ | ||
export interface IpsListResponseBody { | ||
@@ -2,0 +3,0 @@ assignable_to_pools: boolean; |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable camelcase */ | ||
export interface ListsQuery { | ||
@@ -2,0 +3,0 @@ address?: string; |
@@ -1,3 +0,9 @@ | ||
import {MailingList} from './lists'; | ||
import { MailingList } from './lists'; | ||
export interface MailListMember { | ||
address: string; | ||
name: string; | ||
subscribed: boolean, | ||
vars: string | any; | ||
} | ||
export interface MailListMembersQuery { | ||
@@ -34,9 +40,2 @@ subscribed?: 'yes' | 'no'; | ||
export interface MailListMember { | ||
address: string; | ||
name: string; | ||
subscribed: boolean, | ||
vars: string | any; | ||
} | ||
export interface DeletedMember { | ||
@@ -58,6 +57,13 @@ member: { | ||
getMember(address: string, memberAddress: string): Promise<MailListMember>, | ||
createMember(mailListAddress: string, data: CreateUpdateMailListMembers): Promise<MailListMember>, | ||
createMembers(mailListAddress: string, data: MultipleMembersData): Promise<NewMultipleMembersResponse>, | ||
updateMember(address : string, memberAddress: string, data:CreateUpdateMailListMembers): Promise<MailListMember> , | ||
createMember( | ||
mailListAddress: string, | ||
data: CreateUpdateMailListMembers): Promise<MailListMember>, | ||
createMembers( | ||
mailListAddress: string, | ||
data: MultipleMembersData): Promise<NewMultipleMembersResponse>, | ||
updateMember( | ||
address: string, | ||
memberAddress: string, | ||
data: CreateUpdateMailListMembers): Promise<MailListMember>, | ||
destroyMember(address : string, memberAddress: string): Promise<DeletedMember> | ||
} | ||
} |
@@ -1,2 +0,3 @@ | ||
export default interface Options { | ||
/* eslint-disable camelcase */ | ||
interface Options { | ||
username: string; | ||
@@ -7,2 +8,4 @@ key: string; | ||
timeout?: number; | ||
} | ||
} | ||
export default Options; |
import Options from './Options'; | ||
export default interface RequestOptions extends Options { | ||
interface RequestOptions extends Options { | ||
headers: any; | ||
timeout: number; | ||
} | ||
} | ||
export default RequestOptions; |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable camelcase */ | ||
export interface Route { | ||
@@ -2,0 +3,0 @@ actions: string[]; |
@@ -1,2 +0,2 @@ | ||
export default interface StatsOptions { | ||
interface StatsOptions { | ||
start: string | Date; | ||
@@ -13,2 +13,4 @@ end: string | Date; | ||
}[]; | ||
} | ||
} | ||
export default StatsOptions; |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable camelcase */ | ||
export interface BounceData { | ||
@@ -18,2 +19,1 @@ address: string; | ||
} | ||
@@ -1,15 +0,16 @@ | ||
const MgRequest = require('./request'); | ||
/* eslint-disable camelcase */ | ||
import Request from './request'; | ||
import { IpPool } from "./interfaces/IpPools"; | ||
import { IpPool, IpPoolListResponse, IpPoolUpdateData } from './interfaces/IpPools'; | ||
export default class IpPoolsClient { | ||
request: typeof MgRequest; | ||
request: Request; | ||
constructor(request: typeof MgRequest) { | ||
constructor(request: Request) { | ||
this.request = request; | ||
} | ||
list(query: any): IpPool[] { | ||
list(query: any): Promise<IpPool[]> { | ||
return this.request.get('/v1/ip_pools', query) | ||
.then((response: { body: { ip_pools: IpPool, message: string } }) => this.parseIpPoolsResponse(response)); | ||
.then((response: IpPoolListResponse) => this.parseIpPoolsResponse(response)); | ||
} | ||
@@ -22,3 +23,3 @@ | ||
update(poolId: string, data: { name: string, description: string, add_ip: string, remove_ip: string }) { | ||
update(poolId: string, data: IpPoolUpdateData) : Promise<any> { | ||
return this.request.patch(`/v1/ip_pools/${poolId}`, data) | ||
@@ -25,0 +26,0 @@ .then((response: { body: any }) => response?.body); |
@@ -1,8 +0,8 @@ | ||
const MgRequest = require('./request'); | ||
import MgRequest from './request'; | ||
import { IpData, IpsListResponseBody } from './interfaces/Ips'; | ||
export default class IpsClient { | ||
request: typeof MgRequest; | ||
request: MgRequest; | ||
constructor(request: typeof MgRequest) { | ||
constructor(request: MgRequest) { | ||
this.request = request; | ||
@@ -9,0 +9,0 @@ } |
@@ -8,3 +8,3 @@ import Request from './request'; | ||
} from './interfaces/lists'; | ||
import {IMailListsMembers} from './interfaces/mailListMembers'; | ||
import { IMailListsMembers } from './interfaces/mailListMembers'; | ||
@@ -11,0 +11,0 @@ export default class ListsClient { |
@@ -1,2 +0,2 @@ | ||
import Request from "./request"; | ||
import Request from './request'; | ||
@@ -3,0 +3,0 @@ export default class MessagesClient { |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable camelcase */ | ||
import Request from './request'; | ||
@@ -14,7 +15,7 @@ | ||
if (Array.isArray(addresses)) { | ||
addresses = addresses.join(','); | ||
query.addresses = addresses.join(','); | ||
} else { | ||
query.addresses = addresses; | ||
} | ||
query.addresses = addresses; | ||
if (enableDnsEspChecks) { | ||
@@ -21,0 +22,0 @@ query.syntax_only = false; |
@@ -16,4 +16,5 @@ import urljoin from 'url-join'; | ||
this.stats = data.stats.map(function (stat: { time: string | Date }) { | ||
stat.time = new Date(stat.time); | ||
return stat; | ||
const res = { ...stat }; | ||
res.time = new Date(stat.time); | ||
return res; | ||
}); | ||
@@ -20,0 +21,0 @@ } |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable camelcase */ | ||
import url from 'url'; | ||
@@ -7,4 +8,2 @@ import urljoin from 'url-join'; | ||
type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe; | ||
const createOptions = { | ||
@@ -56,2 +55,4 @@ headers: { 'Content-Type': 'application/json' } | ||
type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe; | ||
export default class SuppressionClient { | ||
@@ -89,6 +90,7 @@ request: any; | ||
return pages.reduce( | ||
(acc: any, [id, url]: [url: string, id: string]) => { | ||
acc[id] = this._parsePage(id, url) | ||
return acc | ||
}, {}); | ||
(acc: any, [id, pageUrl]: [pageUrl: string, id: string]) => { | ||
acc[id] = this._parsePage(id, pageUrl); | ||
return acc; | ||
}, {} | ||
); | ||
} | ||
@@ -128,9 +130,12 @@ | ||
// supports adding multiple suppressions by default | ||
let postData; | ||
if (!Array.isArray(data)) { | ||
data = [data]; | ||
postData = [data]; | ||
} else { | ||
postData = { ...data }; | ||
} | ||
return this.request | ||
.post(urljoin('v3', domain, type), data, createOptions) | ||
.then((response: { body: any }) => response.body); | ||
.post(urljoin('v3', domain, type), postData, createOptions) | ||
.then((response: { body: any }) => response.body); | ||
} | ||
@@ -140,4 +145,4 @@ | ||
return this.request | ||
.delete(urljoin('v3', domain, type, encodeURIComponent(address))) | ||
.then((response: { body: any }) => response.body); | ||
.delete(urljoin('v3', domain, type, encodeURIComponent(address))) | ||
.then((response: { body: any }) => response.body); | ||
} | ||
@@ -144,0 +149,0 @@ } |
@@ -1,2 +0,1 @@ | ||
import Request from './request'; | ||
@@ -3,0 +2,0 @@ |
{ | ||
"name": "mailgun.js", | ||
"version": "3.6.1", | ||
"version": "3.7.0", | ||
"main": "dist/mailgun.node.js", | ||
@@ -5,0 +5,0 @@ "browser": "dist/mailgun.web.js", |
@@ -20,3 +20,8 @@ import formData from 'form-data'; | ||
beforeEach(function () { | ||
client = new Client({ username: 'username', key: 'key', public_key: 'key', timeout: 10000 }, formData); | ||
client = new Client({ | ||
username: 'username', | ||
key: 'key', | ||
public_key: 'key', | ||
timeout: 10000 | ||
}, formData); | ||
}); | ||
@@ -27,3 +32,3 @@ | ||
function () { | ||
return new Client({ key: 'key' } as any, formData) | ||
return new Client({ key: 'key' } as any, formData); | ||
} | ||
@@ -30,0 +35,0 @@ ).to.throw('Parameter "username" is required'); |
import nock from 'nock'; | ||
import formData from 'form-data'; | ||
import EventClient from '../lib/events'; | ||
import formData from 'form-data'; | ||
import MgRequest from '../lib/request'; | ||
@@ -6,0 +6,0 @@ import RequestOptions from '../lib/interfaces/RequestOptions'; |
// const formData = require('form-data'); | ||
import nock from 'nock'; | ||
import formData from 'form-data'; | ||
import Request from '../lib/request'; | ||
import RequestOptions from '../lib/interfaces/RequestOptions'; | ||
import IpsClient from '../lib/ips'; | ||
import formData from 'form-data'; | ||
@@ -9,0 +9,0 @@ import { IpData, IpsListResponseBody } from '../lib/interfaces/Ips'; |
import nock from 'nock'; | ||
import formData from 'form-data'; | ||
import Request from '../lib/request'; | ||
@@ -7,3 +9,2 @@ import ListsClient from '../lib/lists'; | ||
import { MailingList } from '../lib/interfaces/lists'; | ||
import formData from 'form-data'; | ||
@@ -28,3 +29,3 @@ describe('ListsClient', function () { | ||
reply_preference: null | ||
} as MailingList | ||
} as MailingList; | ||
}); | ||
@@ -44,4 +45,4 @@ | ||
return client.list().then(function (lists: MailingList[]) { | ||
lists[0].should.eql(defaultList); | ||
return client.list().then(function (listsRes: MailingList[]) { | ||
listsRes[0].should.eql(defaultList); | ||
}); | ||
@@ -53,3 +54,2 @@ }); | ||
it('gets a specific mailing list', function () { | ||
api.get('/v3/lists/testing.example.com').reply(200, { | ||
@@ -67,3 +67,2 @@ list: defaultList | ||
it('creates the list', function () { | ||
api.post('/v3/lists').reply(200, { | ||
@@ -70,0 +69,0 @@ list: defaultList |
import nock from 'nock'; | ||
import formData from 'form-data'; | ||
import Request from '../lib/request'; | ||
@@ -6,3 +7,2 @@ import RequestOptions from '../lib/interfaces/RequestOptions'; | ||
import { DeletedMember, MailListMember, NewMultipleMembersResponse } from '../lib/interfaces/mailListMembers'; | ||
import formData from 'form-data'; | ||
@@ -23,3 +23,3 @@ describe('mailListsMembersClient', function () { | ||
vars: { gender: 'female', age: 0 } | ||
} as MailListMember | ||
} as MailListMember; | ||
}); | ||
@@ -62,3 +62,3 @@ | ||
it('adds list member to the mailing list ', function () { | ||
const member:any = {...defaultListMember}; | ||
const member:any = { ...defaultListMember }; | ||
member.subscribed = true; | ||
@@ -72,8 +72,8 @@ const mailingListAddress = 'testingMailingListAddress@example.com'; | ||
newListMember.should.eql(member); | ||
}) | ||
}); | ||
}); | ||
it('works with string value in subscribed field', function () { | ||
const member:any = {...defaultListMember}; | ||
member.subscribed = "yes"; | ||
const member:any = { ...defaultListMember }; | ||
member.subscribed = 'yes'; | ||
const mailingListAddress = 'testingMailingListAddress@example.com'; | ||
@@ -86,3 +86,3 @@ api.post(`/v3/lists/${mailingListAddress}/members`).reply(200, { | ||
newListMember.should.eql(member); | ||
}) | ||
}); | ||
}); | ||
@@ -92,4 +92,4 @@ }); | ||
describe('createMembers', function () { | ||
const mailingListAddress : string = 'testingMailingListAddress@example.com'; | ||
let response : NewMultipleMembersResponse; | ||
const mailingListAddress = 'testingMailingListAddress@example.com'; | ||
let response : NewMultipleMembersResponse; | ||
@@ -114,11 +114,9 @@ beforeEach(function () { | ||
const newMembersListPlaceholder = new Array(5).fill(0); | ||
const newMembersList = newMembersListPlaceholder.map((_, index)=>{ | ||
return { | ||
address: `test${index}@example.com`, | ||
name: `test name ${index}`, | ||
vars: {gender:"female", age:index}, | ||
subscribed: true, | ||
upsert: 'yes' | ||
}; | ||
}); | ||
const newMembersList = newMembersListPlaceholder.map((_, index) => ({ | ||
address: `test${index}@example.com`, | ||
name: `test name ${index}`, | ||
vars: { gender: 'female', age: index }, | ||
subscribed: true, | ||
upsert: 'yes' | ||
})); | ||
@@ -129,6 +127,6 @@ api.post(`/v3/lists/${mailingListAddress}/members.json`).reply(200, response); | ||
members: newMembersList, | ||
upsert: "yes" | ||
upsert: 'yes' | ||
}).then(function (result: NewMultipleMembersResponse) { | ||
result.should.eql(response); | ||
}) | ||
}); | ||
}); | ||
@@ -138,20 +136,18 @@ | ||
const newMembersListPlaceholder = new Array(5).fill(0); | ||
const newMembersList = newMembersListPlaceholder.map((_, index)=>{ | ||
return { | ||
address: `test${index}@example.com`, | ||
name: `test name ${index}`, | ||
vars: JSON.stringify({gender:"female", age:index}), | ||
subscribed: true, | ||
upsert: 'yes' | ||
}; | ||
}); | ||
const newMembersList = newMembersListPlaceholder.map((_, index) => ({ | ||
address: `test${index}@example.com`, | ||
name: `test name ${index}`, | ||
vars: JSON.stringify({ gender: 'female', age: index }), | ||
subscribed: true, | ||
upsert: 'yes' | ||
})); | ||
api.post(`/v3/lists/${mailingListAddress}/members.json`).reply(200, response); | ||
return client.createMembers(mailingListAddress, { | ||
members: newMembersList, | ||
upsert: "yes" | ||
upsert: 'yes' | ||
}).then(function (result: NewMultipleMembersResponse) { | ||
result.should.eql(response); | ||
}) | ||
}); | ||
}); | ||
}); | ||
@@ -163,5 +159,9 @@ | ||
const mailingListMemberAddress = 'testingMailingListMemberAddress@example.com'; | ||
api.put(`/v3/lists/${mailingListAddress}/members/${mailingListMemberAddress}`).reply(200, {member: defaultListMember}); | ||
api.put(`/v3/lists/${mailingListAddress}/members/${mailingListMemberAddress}`).reply(200, { member: defaultListMember }); | ||
return client.updateMember(mailingListAddress, mailingListMemberAddress, defaultListMember).then(function (res: MailListMember) { | ||
return client.updateMember( | ||
mailingListAddress, | ||
mailingListMemberAddress, | ||
defaultListMember | ||
).then(function (res: MailListMember) { | ||
res.should.eql(defaultListMember); | ||
@@ -174,7 +174,11 @@ }); | ||
const mailingListMemberAddress = 'testingMailingListMemberAddress@example.com'; | ||
const member:any = {...defaultListMember}; | ||
member.subscribed = "yes"; | ||
api.put(`/v3/lists/${mailingListAddress}/members/${mailingListMemberAddress}`).reply(200, {member: defaultListMember}); | ||
const member: any = { ...defaultListMember }; | ||
member.subscribed = 'yes'; | ||
api.put(`/v3/lists/${mailingListAddress}/members/${mailingListMemberAddress}`).reply(200, { member: defaultListMember }); | ||
return client.updateMember(mailingListAddress, mailingListMemberAddress, member).then(function (res: MailListMember) { | ||
return client.updateMember( | ||
mailingListAddress, | ||
mailingListMemberAddress, | ||
member | ||
).then(function (res: MailListMember) { | ||
res.should.eql(defaultListMember); | ||
@@ -186,3 +190,2 @@ }); | ||
describe('destroyMember', function () { | ||
it('deletes member from the list ', function () { | ||
@@ -193,3 +196,3 @@ const mailingListAddress = 'testingMailingListAddress@example.com'; | ||
member: defaultListMember, | ||
message: "deleted" | ||
message: 'deleted' | ||
} as DeletedMember; | ||
@@ -199,3 +202,6 @@ | ||
return client.destroyMember(mailingListAddress, mailingListMemberAddress).then(function (deletedMemberRes: DeletedMember) { | ||
return client.destroyMember( | ||
mailingListAddress, | ||
mailingListMemberAddress | ||
).then(function (deletedMemberRes: DeletedMember) { | ||
deletedMemberRes.should.eql(res); | ||
@@ -205,3 +211,2 @@ }); | ||
}); | ||
}); |
import fs from 'fs'; | ||
import nock from 'nock'; | ||
import { expect } from 'chai'; | ||
import formData from 'form-data'; | ||
@@ -7,4 +9,2 @@ import Request from '../lib/request'; | ||
import RequestOptions from '../lib/interfaces/RequestOptions'; | ||
import { expect } from 'chai'; | ||
import formData from 'form-data'; | ||
@@ -45,3 +45,3 @@ const mailgunLogo = fs.createReadStream(`${__dirname}/img/mailgun.png`); | ||
}] | ||
}) | ||
}); | ||
@@ -48,0 +48,0 @@ expect(res.message).to.eql('Queued. Thank you.'); |
@@ -1,2 +0,2 @@ | ||
const formData = require('form-data'); // importing this way to not have type error in line 13 | ||
import formData from 'form-data'; // importing this way to not have type error in line 13 | ||
@@ -3,0 +3,0 @@ import fs from 'fs'; |
@@ -13,3 +13,3 @@ import formData from 'form-data'; | ||
unparseable: string[] | ||
}; | ||
} | ||
@@ -16,0 +16,0 @@ describe('ParseClient', function () { |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable camelcase */ | ||
import formData from 'form-data'; | ||
@@ -2,0 +3,0 @@ import nock from 'nock'; |
import chai, { expect } from 'chai'; | ||
chai.should(); | ||
import formData from 'form-data'; | ||
import nock from 'nock'; | ||
import nock from 'nock'; | ||
import Request from '../lib/request'; | ||
@@ -10,2 +9,4 @@ import SuppressionClient from '../lib/suppressions'; | ||
chai.should(); | ||
describe('SuppressionsClient', function () { | ||
@@ -85,3 +86,3 @@ let client: any; | ||
return client.list('domain.com', 'unsubscribes') | ||
.then(function (unsubscribes: { items: any }) { | ||
.then(function (unsubscribes: { items: any }) { | ||
let u; | ||
@@ -88,0 +89,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2209004
163
4488