mailgun.js
Advanced tools
Comparing version 3.5.4 to 3.5.5
@@ -5,2 +5,9 @@ # Changelog | ||
### [3.5.5](https://github.com/mailgun/mailgun-js/compare/v3.5.4...v3.5.5) (2021-08-09) | ||
### Bug Fixes | ||
* Domain.Creates method returns error ([2068c3d](https://github.com/mailgun/mailgun-js/commits/2068c3d37d54df013d6439c8e0b93f6f553173a7)) | ||
### [3.5.4](https://github.com/mailgun/mailgun-js/compare/v3.5.3...v3.5.4) (2021-08-04) | ||
@@ -7,0 +14,0 @@ |
@@ -0,67 +1,40 @@ | ||
import { DomainResponseData, DestroyedDomain, DestroyedDomainResponse, DomainsQuery, DomainInfo, DomainListResponseData, DomainShortData, DNSRecord } from './interfaces/Domains'; | ||
import APIResponse from './interfaces/ApiResponse'; | ||
import Request from './request'; | ||
interface DomainData { | ||
import { DomainTrackingResponse, DomainTrackingData, OpenTrackingInfo, ClickTrackingInfo, UnsubscribeTrackingInfo, UpdateDomainTrackingResponse, UpdatedOpenTracking } from './interfaces/DomainTracking'; | ||
declare class Domain { | ||
name: string; | ||
require_tls: any; | ||
skip_verification: any; | ||
state: any; | ||
wildcard: any; | ||
spam_action: any; | ||
created_at: string | Date; | ||
require_tls: boolean; | ||
skip_verification: boolean; | ||
state: string; | ||
wildcard: boolean; | ||
spam_action: string; | ||
created_at: string; | ||
smtp_password: string; | ||
smtp_login: string; | ||
type: string; | ||
receiving_dns_records: DNSRecord[] | null; | ||
sending_dns_records: DNSRecord[] | null; | ||
constructor(data: DomainShortData, receiving?: DNSRecord[] | null, sending?: DNSRecord[] | null); | ||
} | ||
declare class Domain { | ||
name: any; | ||
require_tls: any; | ||
skip_verification: any; | ||
state: any; | ||
wildcard: any; | ||
spam_action: any; | ||
created_at: any; | ||
smtp_password: any; | ||
smtp_login: any; | ||
type: any; | ||
receiving_dns_records: any; | ||
sending_dns_records: any; | ||
constructor(data: DomainData, receiving?: any, sending?: any); | ||
} | ||
export default class DomainClient { | ||
request: Request; | ||
constructor(request: Request); | ||
_parseMessage(response: { | ||
body: any; | ||
}): any; | ||
_parseDomainList(response: { | ||
body: { | ||
items: DomainData[]; | ||
}; | ||
}): Domain[]; | ||
_parseDomain(response: { | ||
body: { | ||
domain: any; | ||
receiving_dns_records: any; | ||
sending_dns_records: any; | ||
}; | ||
}): Domain; | ||
_parseTrackingSettings(response: { | ||
body: { | ||
tracking: any; | ||
}; | ||
}): any; | ||
_parseTrackingUpdate(response: { | ||
body: any; | ||
}): any; | ||
list(query: any): Promise<Domain[]>; | ||
_parseMessage(response: DestroyedDomainResponse): DestroyedDomain; | ||
_parseDomainList(response: DomainListResponseData): Domain[]; | ||
_parseDomain(response: DomainResponseData): Domain; | ||
_parseTrackingSettings(response: DomainTrackingResponse): DomainTrackingData; | ||
_parseTrackingUpdate(response: UpdateDomainTrackingResponse): UpdatedOpenTracking; | ||
list(query: DomainsQuery): Promise<Domain[]>; | ||
get(domain: string): Promise<Domain>; | ||
create(data: any): Promise<Domain>; | ||
destroy(domain: string): Promise<any>; | ||
getTracking(domain: string): Promise<any>; | ||
updateTracking(domain: string, type: string, data: any): Promise<any>; | ||
create(data: DomainInfo): Promise<Domain>; | ||
destroy(domain: string): Promise<DestroyedDomain>; | ||
getTracking(domain: string): Promise<DomainTrackingData>; | ||
updateTracking(domain: string, type: string, data: OpenTrackingInfo | ClickTrackingInfo | UnsubscribeTrackingInfo): Promise<UpdatedOpenTracking>; | ||
getIps(domain: string): Promise<string[]>; | ||
assignIp(domain: string, ip: string): Promise<import("./interfaces/ApiResponse").default>; | ||
deleteIp(domain: string, ip: string): Promise<import("./interfaces/ApiResponse").default>; | ||
linkIpPool(domain: string, pool_id: string): Promise<import("./interfaces/ApiResponse").default>; | ||
unlinkIpPoll(domain: string, pool_id: string, ip: string): Promise<import("./interfaces/ApiResponse").default>; | ||
assignIp(domain: string, ip: string): Promise<APIResponse>; | ||
deleteIp(domain: string, ip: string): Promise<APIResponse>; | ||
linkIpPool(domain: string, pool_id: string): Promise<APIResponse>; | ||
unlinkIpPoll(domain: string, pool_id: string, ip: string): Promise<APIResponse>; | ||
} | ||
export {}; |
@@ -5,2 +5,2 @@ /*! MIT License © Sindre Sorhus */ | ||
/*! mailgun.js v3.5.3 */ | ||
/*! mailgun.js v3.5.4 */ |
@@ -0,32 +1,44 @@ | ||
/* eslint-disable camelcase */ | ||
import urljoin from 'url-join'; | ||
import { | ||
DomainResponseData, | ||
DestroyedDomain, | ||
DestroyedDomainResponse, | ||
DomainsQuery, | ||
DomainInfo, | ||
DomainListResponseData, | ||
DomainShortData, | ||
DNSRecord | ||
} from './interfaces/Domains'; | ||
import APIResponse from './interfaces/ApiResponse'; | ||
import APIError from './error'; | ||
import APIErrorOptions from './interfaces/APIErrorOptions'; | ||
import Request from './request'; | ||
import { | ||
DomainTrackingResponse, | ||
DomainTrackingData, | ||
OpenTrackingInfo, | ||
ClickTrackingInfo, | ||
UnsubscribeTrackingInfo, | ||
UpdateDomainTrackingResponse, | ||
UpdatedOpenTracking | ||
} from './interfaces/DomainTracking'; | ||
interface DomainData { | ||
class Domain { | ||
name: string; | ||
require_tls: any; | ||
skip_verification: any; | ||
state: any; | ||
wildcard: any; | ||
spam_action: any; | ||
created_at: string | Date; | ||
require_tls: boolean; | ||
skip_verification: boolean; | ||
state: string; | ||
wildcard: boolean; | ||
spam_action: string; | ||
created_at: string; | ||
smtp_password: string; | ||
smtp_login: string; | ||
type: string; | ||
} | ||
receiving_dns_records: DNSRecord[] | null; | ||
sending_dns_records: DNSRecord[] | null; | ||
class Domain { | ||
name: any; | ||
require_tls: any; | ||
skip_verification: any; | ||
state: any; | ||
wildcard: any; | ||
spam_action: any; | ||
created_at: any; | ||
smtp_password: any; | ||
smtp_login: any; | ||
type: any; | ||
receiving_dns_records: any; | ||
sending_dns_records: any; | ||
constructor(data: DomainData, receiving?: any, sending?: any) { | ||
constructor(data: DomainShortData, receiving?: DNSRecord[] | null, sending?: DNSRecord[] | null) { | ||
this.name = data.name; | ||
@@ -55,7 +67,7 @@ this.require_tls = data.require_tls; | ||
_parseMessage(response: { body: any }) { | ||
_parseMessage(response: DestroyedDomainResponse) : DestroyedDomain { | ||
return response.body; | ||
} | ||
_parseDomainList(response: { body: { items: DomainData[] } }) { | ||
_parseDomainList(response: DomainListResponseData): Domain[] { | ||
return response.body.items.map(function (item) { | ||
@@ -66,9 +78,3 @@ return new Domain(item); | ||
_parseDomain(response: { | ||
body: { | ||
domain: any, | ||
receiving_dns_records: any, | ||
sending_dns_records: any | ||
} | ||
}) { | ||
_parseDomain(response: DomainResponseData): Domain { | ||
return new Domain( | ||
@@ -81,28 +87,28 @@ response.body.domain, | ||
_parseTrackingSettings(response: { body: { tracking: any } }) { | ||
_parseTrackingSettings(response: DomainTrackingResponse) : DomainTrackingData { | ||
return response.body.tracking; | ||
} | ||
_parseTrackingUpdate(response: { body: any }) { | ||
_parseTrackingUpdate(response: UpdateDomainTrackingResponse) :UpdatedOpenTracking { | ||
return response.body; | ||
} | ||
list(query: any) { | ||
list(query: DomainsQuery): Promise<Domain[]> { | ||
return this.request.get('/v2/domains', query) | ||
.then(this._parseDomainList); | ||
.then((res : APIResponse) => this._parseDomainList(res as DomainListResponseData)); | ||
} | ||
get(domain: string) { | ||
get(domain: string) : Promise<Domain> { | ||
return this.request.get(`/v2/domains/${domain}`) | ||
.then(this._parseDomain); | ||
.then((res : APIResponse) => this._parseDomain(res as DomainResponseData)); | ||
} | ||
create(data: any) { | ||
return this.request.post('/v2/domains', data) | ||
.then(this._parseDomain); | ||
create(data: DomainInfo) : Promise<Domain> { | ||
return this.request.postWithFD('/v2/domains', data) | ||
.then((res : APIResponse) => this._parseDomain(res as DomainResponseData)); | ||
} | ||
destroy(domain: string) { | ||
destroy(domain: string): Promise<DestroyedDomain> { | ||
return this.request.delete(`/v2/domains/${domain}`) | ||
.then(this._parseMessage); | ||
.then((res : APIResponse) => this._parseMessage(res as DestroyedDomainResponse)); | ||
} | ||
@@ -112,3 +118,3 @@ | ||
getTracking(domain: string) { | ||
getTracking(domain: string) : Promise<DomainTrackingData> { | ||
return this.request.get(urljoin('/v2/domains', domain, 'tracking')) | ||
@@ -118,4 +124,11 @@ .then(this._parseTrackingSettings); | ||
updateTracking(domain: string, type: string, data: any) { | ||
return this.request.put(urljoin('/v2/domains', domain, 'tracking', type), data) | ||
updateTracking( | ||
domain: string, | ||
type: string, | ||
data: OpenTrackingInfo | ClickTrackingInfo | UnsubscribeTrackingInfo | ||
): Promise<UpdatedOpenTracking> { | ||
if (!('html_footer' in data) && !('text_footer' in data) && typeof data?.active === 'boolean') { | ||
throw new APIError({ status: 400, statusText: '', body: { message: 'Value "active" must contain string value.' } } as APIErrorOptions); | ||
} | ||
return this.request.putWithFD(urljoin('/v2/domains', domain, 'tracking', type), data) | ||
.then(this._parseTrackingUpdate); | ||
@@ -126,22 +139,22 @@ } | ||
getIps(domain: string) { | ||
getIps(domain: string): Promise<string[]> { | ||
return this.request.get(urljoin('/v2/domains', domain, 'ips')) | ||
.then((response: { body: { items: string[] } }) => response?.body?.items); | ||
.then((response: APIResponse) => response?.body?.items); | ||
} | ||
assignIp(domain: string, ip: string) { | ||
return this.request.post(urljoin('/v2/domains', domain, 'ips'), { ip }); | ||
assignIp(domain: string, ip: string): Promise<APIResponse> { | ||
return this.request.postWithFD(urljoin('/v2/domains', domain, 'ips'), { ip }); | ||
} | ||
deleteIp(domain: string, ip: string) { | ||
deleteIp(domain: string, ip: string): Promise<APIResponse> { | ||
return this.request.delete(urljoin('/v2/domains', domain, 'ips', ip)); | ||
} | ||
linkIpPool(domain: string, pool_id: string) { | ||
return this.request.post(urljoin('/v2/domains', domain, 'ips'), { pool_id }); | ||
linkIpPool(domain: string, pool_id: string): Promise<APIResponse> { | ||
return this.request.postWithFD(urljoin('/v2/domains', domain, 'ips'), { pool_id }); | ||
} | ||
unlinkIpPoll(domain: string, pool_id: string, ip: string) { | ||
unlinkIpPoll(domain: string, pool_id: string, ip: string): Promise<APIResponse> { | ||
return this.request.delete(urljoin('/v2/domains', domain, 'ips', 'ip_pool'), { pool_id, ip }); | ||
} | ||
} |
{ | ||
"name": "mailgun.js", | ||
"version": "3.5.4", | ||
"version": "3.5.5", | ||
"main": "dist/mailgun.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -1,8 +0,8 @@ | ||
const formData = require('form-data'); | ||
import formData from 'form-data'; | ||
import nock from 'nock'; | ||
import { expect } from 'chai'; | ||
import Request from '../lib/request'; | ||
import DomainClient from '../lib/domains'; | ||
import RequestOptions from '../lib/interfaces/RequestOptions'; | ||
import { expect } from 'chai'; | ||
@@ -175,7 +175,8 @@ // TODO: fix types | ||
api.put('/v2/domains/domain.com/tracking/open').reply(200, { | ||
message: 'Tracking settings have been updated', | ||
open | ||
}); | ||
message: 'Tracking settings have been updated', | ||
open | ||
}); | ||
const res = await client.updateTracking('domain.com', 'open', { active: true }) | ||
const res = await client.updateTracking('domain.com', 'open', { active: 'yes' }); | ||
expect(res).to.eql({ | ||
@@ -192,7 +193,7 @@ message: 'Tracking settings have been updated', | ||
it('should return list of dedicated ips', () => { | ||
const items = ['192.161.0.1', '192.168.0.2'] | ||
const items = ['192.161.0.1', '192.168.0.2']; | ||
api.get('/v2/domains/domain.com/ips').reply(200, { items }); | ||
return client.getIps('domain.com').then( (items: string[]) => { | ||
items.should.eql(items); | ||
return client.getIps('domain.com').then((response: string[]) => { | ||
response.should.eql(items); | ||
}); | ||
@@ -199,0 +200,0 @@ }); |
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
1916022
160
4136