mailgun.js
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [4.1.0](https://github.com/mailgun/mailgun.js/compare/v4.0.1...v4.1.0) (2021-11-30) | ||
### Features | ||
* Add support of whitelists into suppressions client ([#214](https://github.com/mailgun/mailgun.js/issues/214)) ([1e4fb84](https://github.com/mailgun/mailgun.js/commits/1e4fb84d2528751a9c2dddd1599d2bc0e12b1fdd)) | ||
### [4.0.1](https://github.com/mailgun/mailgun.js/compare/v4.0.0...v4.0.1) (2021-11-25) | ||
@@ -7,0 +14,0 @@ |
@@ -16,1 +16,7 @@ export interface BounceData { | ||
} | ||
export interface WhiteListData { | ||
type: string; | ||
value: string; | ||
reason: string; | ||
createdAt: string | Date; | ||
} |
import Request from './request'; | ||
import { BounceData, ComplaintData, UnsubscribeData } from './interfaces/Supressions'; | ||
import { BounceData, ComplaintData, UnsubscribeData, WhiteListData } from './interfaces/Supressions'; | ||
declare class Bounce { | ||
@@ -24,3 +24,10 @@ type: string; | ||
} | ||
declare type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe; | ||
declare class WhiteList { | ||
type: string; | ||
value: string; | ||
reason: string; | ||
createdAt: Date; | ||
constructor(data: WhiteListData); | ||
} | ||
declare type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe | typeof WhiteList; | ||
export default class SuppressionClient { | ||
@@ -32,2 +39,3 @@ request: any; | ||
unsubscribes: typeof Unsubscribe; | ||
whitelists: typeof WhiteList; | ||
}; | ||
@@ -54,3 +62,4 @@ constructor(request: Request); | ||
body: any; | ||
}, Model: TModel): Bounce | Complaint | Unsubscribe; | ||
}, Model: TModel): Bounce | Complaint | Unsubscribe | WhiteList; | ||
private createWhiteList; | ||
list(domain: string, type: string, query: any): any; | ||
@@ -57,0 +66,0 @@ get(domain: string, type: string, address: string): any; |
@@ -5,2 +5,2 @@ /*! MIT License © Sindre Sorhus */ | ||
/*! mailgun.js v4.0.0 */ | ||
/*! mailgun.js v4.0.1 */ |
@@ -7,2 +7,2 @@ /*! MIT License © Sindre Sorhus */ | ||
/*! mailgun.js v4.0.0 */ | ||
/*! mailgun.js v4.0.1 */ |
@@ -19,1 +19,8 @@ /* eslint-disable camelcase */ | ||
} | ||
export interface WhiteListData { | ||
type: string; | ||
value: string; | ||
reason: string; | ||
createdAt: string | Date; | ||
} |
@@ -6,3 +6,8 @@ /* eslint-disable camelcase */ | ||
import Request from './request'; | ||
import { BounceData, ComplaintData, UnsubscribeData } from './interfaces/Supressions'; | ||
import { | ||
BounceData, | ||
ComplaintData, | ||
UnsubscribeData, | ||
WhiteListData | ||
} from './interfaces/Supressions'; | ||
@@ -55,4 +60,18 @@ const createOptions = { | ||
type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe; | ||
class WhiteList { | ||
type: string; | ||
value: string; | ||
reason: string; | ||
createdAt: Date; | ||
constructor(data: WhiteListData) { | ||
this.type = 'whitelists'; | ||
this.value = data.value; | ||
this.reason = data.reason; | ||
this.createdAt = new Date(data.createdAt); | ||
} | ||
} | ||
type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe | typeof WhiteList; | ||
export default class SuppressionClient { | ||
@@ -64,2 +83,3 @@ request: any; | ||
unsubscribes: typeof Unsubscribe; | ||
whitelists: typeof WhiteList; | ||
}; | ||
@@ -72,3 +92,4 @@ | ||
complaints: Complaint, | ||
unsubscribes: Unsubscribe | ||
unsubscribes: Unsubscribe, | ||
whitelists: WhiteList, | ||
}; | ||
@@ -113,2 +134,8 @@ } | ||
private createWhiteList(domain: string, data: any) { | ||
return this.request | ||
.postWithFD(urljoin('v3', domain, 'whitelists'), data, createOptions) | ||
.then((response: { body: any }) => response.body); | ||
} | ||
list(domain: string, type: string, query: any) { | ||
@@ -133,10 +160,14 @@ const model = (this.models as any)[type]; | ||
let postData; | ||
if (type === 'whitelists') { | ||
return this.createWhiteList(domain, data); | ||
} | ||
if (!Array.isArray(data)) { | ||
postData = [data]; | ||
} else { | ||
postData = { ...data }; | ||
postData = [...data]; | ||
} | ||
return this.request | ||
.post(urljoin('v3', domain, type), postData, createOptions) | ||
.post(urljoin('v3', domain, type), JSON.stringify(postData), createOptions) | ||
.then((response: { body: any }) => response.body); | ||
@@ -143,0 +174,0 @@ } |
{ | ||
"name": "mailgun.js", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"main": "dist/mailgun.node.js", | ||
@@ -5,0 +5,0 @@ "browser": "dist/mailgun.web.js", |
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
2292684
5547