diff --git a/lib/client.ts b/lib/client.ts index 2ed926c6..81dca644 100644 --- a/lib/client.ts +++ b/lib/client.ts @@ -1,7 +1,7 @@ /* eslint-disable camelcase */ import Request from './request'; -import Options from './interfaces/Options'; -import { RequestOptions } from './interfaces/RequestOptions'; +import { Options } from './types/Options'; +import { RequestOptions } from './types/RequestOptions'; import DomainClient from './domains'; import EventClient from './events'; @@ -15,12 +15,12 @@ import IpsClient from './ips'; import IpPoolsClient from './ip-pools'; import ListsClient from './lists'; import MailListsMembers from './mailListMembers'; -import { InputFormData } from './interfaces/IFormData'; +import { InputFormData } from './types/IFormData'; import DomainCredentialsClient from './domainsCredentials'; import MultipleValidationClient from './multipleValidation'; import DomainTemplatesClient from './domainsTemplates'; import DomainTagsClient from './domainsTags'; -import { IMailgunClient } from './interfaces/IMailgunClient'; +import { IMailgunClient } from './types/IMailgunClient'; export default class Client implements IMailgunClient { private request; diff --git a/lib/common/NavigationThruPages.ts b/lib/common/NavigationThruPages.ts index 5106d8a5..b6c0574d 100644 --- a/lib/common/NavigationThruPages.ts +++ b/lib/common/NavigationThruPages.ts @@ -1,6 +1,6 @@ import urljoin from 'url-join'; import APIError from '../error'; -import APIErrorOptions from '../interfaces/APIErrorOptions'; +import { APIErrorOptions } from '../types/APIErrorOptions'; import { PagesListAccumulator, ParsedPage, @@ -8,11 +8,11 @@ import { QueryWithPage, ResponseWithPaging, UpdatedUrlAndQuery -} from '../interfaces/NavigationThruPages'; -import { BounceData, IBounce } from '../interfaces/Suppressions/Bounce'; -import { ComplaintData, IComplaint } from '../interfaces/Suppressions/Complaint'; -import { IUnsubscribe, UnsubscribeData } from '../interfaces/Suppressions/Unsubscribe'; -import { IWhiteList, WhiteListData } from '../interfaces/Suppressions/WhiteList'; +} from '../types/NavigationThruPages'; +import { BounceData, IBounce } from '../types/Suppressions/Bounce'; +import { ComplaintData, IComplaint } from '../types/Suppressions/Complaint'; +import { IUnsubscribe, UnsubscribeData } from '../types/Suppressions/Unsubscribe'; +import { IWhiteList, WhiteListData } from '../types/Suppressions/WhiteList'; import Request from '../request'; export default abstract class NavigationThruPages { diff --git a/lib/domains.ts b/lib/domains.ts index 9557aff0..3ec0c5fb 100644 --- a/lib/domains.ts +++ b/lib/domains.ts @@ -21,11 +21,11 @@ import { UpdatedWebPrefixResponse, ReplacementForPool, MessageResponse, -} from './interfaces/Domains'; +} from './types/Domains'; -import APIResponse from './interfaces/ApiResponse'; +import { APIResponse } from './types/ApiResponse'; import APIError from './error'; -import APIErrorOptions from './interfaces/APIErrorOptions'; +import { APIErrorOptions } from './types/APIErrorOptions'; import Request from './request'; import { @@ -36,12 +36,12 @@ import { UnsubscribeTrackingInfo, UpdateDomainTrackingResponse, UpdatedOpenTracking -} from './interfaces/DomainTracking'; -import { IDomainCredentials } from './interfaces/DomainCredentials'; -import { IDomainTemplatesClient } from './interfaces/DomainTemplates'; +} from './types/DomainTracking'; +import { IDomainCredentials } from './types/DomainCredentials'; +import { IDomainTemplatesClient } from './types/DomainTemplates'; import DomainCredentialsClient from './domainsCredentials'; import DomainTemplatesClient from './domainsTemplates'; -import { IDomainTagsClient } from './interfaces/DomainTags'; +import { IDomainTagsClient } from './types/DomainTags'; import DomainTagsClient from './domainsTags'; export class Domain { diff --git a/lib/domainsCredentials.ts b/lib/domainsCredentials.ts index eec63d65..02a13a57 100644 --- a/lib/domainsCredentials.ts +++ b/lib/domainsCredentials.ts @@ -1,5 +1,5 @@ import urljoin from 'url-join'; -import APIResponse from './interfaces/ApiResponse'; +import { APIResponse } from './types/ApiResponse'; import Request from './request'; import { @@ -12,7 +12,7 @@ import { DomainCredentialsResult, IDomainCredentials, UpdateDomainCredentialsData -} from './interfaces/DomainCredentials'; +} from './types/DomainCredentials'; export default class DomainCredentialsClient implements IDomainCredentials { baseRoute: string; diff --git a/lib/domainsTags.ts b/lib/domainsTags.ts index 6c848e36..f162afb1 100644 --- a/lib/domainsTags.ts +++ b/lib/domainsTags.ts @@ -1,5 +1,5 @@ import urljoin from 'url-join'; -import APIResponse from './interfaces/ApiResponse'; +import { APIResponse } from './types/ApiResponse'; import Request from './request'; import { @@ -22,7 +22,7 @@ import { DomainTagStatisticResult, IDomainTagsClient, Resolution -} from './interfaces/DomainTags'; +} from './types/DomainTags'; import NavigationThruPages from './common/NavigationThruPages'; export class DomainTag implements DomainTagsItem { diff --git a/lib/domainsTemplates.ts b/lib/domainsTemplates.ts index ce57e877..02738ccb 100644 --- a/lib/domainsTemplates.ts +++ b/lib/domainsTemplates.ts @@ -25,7 +25,7 @@ import { TemplateVersion, UpdateOrDeleteDomainTemplateAPIResponse, UpdateOrDeleteDomainTemplateResult -} from './interfaces/DomainTemplates'; +} from './types/DomainTemplates'; import NavigationThruPages from './common/NavigationThruPages'; export class DomainTemplateItem implements DomainTemplate { diff --git a/lib/error.ts b/lib/error.ts index 6c47325c..1a0e6391 100644 --- a/lib/error.ts +++ b/lib/error.ts @@ -1,4 +1,4 @@ -import APIErrorOptions from './interfaces/APIErrorOptions'; +import { APIErrorOptions } from './types/APIErrorOptions'; export default class APIError extends Error { status: number | string; diff --git a/lib/events.ts b/lib/events.ts index f195b020..4e7fdbe3 100644 --- a/lib/events.ts +++ b/lib/events.ts @@ -4,7 +4,7 @@ import { EventsList, EventsQuery, EventsResponse, -} from './interfaces/Events'; +} from './types/Events'; import Request from './request'; diff --git a/lib/formDataBuilder.ts b/lib/formDataBuilder.ts index a5134e46..34fed881 100644 --- a/lib/formDataBuilder.ts +++ b/lib/formDataBuilder.ts @@ -1,5 +1,5 @@ import * as NodeFormData from 'form-data'; -import { InputFormData } from './interfaces/IFormData'; +import { InputFormData } from './types/IFormData'; class FormDataBuilder { private FormDataConstructor: InputFormData; diff --git a/lib/index.ts b/lib/index.ts index dc39216d..3e4d33f9 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,6 +1,7 @@ import Client from './client'; -import { InputFormData } from './interfaces/IFormData'; -import Options from './interfaces/Options'; +import { InputFormData, Options } from './types'; + +export * from './types'; export default class Mailgun { static get default(): typeof Mailgun { return this; } diff --git a/lib/interfaces/ApiResponse.ts b/lib/interfaces/ApiResponse.ts deleted file mode 100644 index e767dd42..00000000 --- a/lib/interfaces/ApiResponse.ts +++ /dev/null @@ -1,6 +0,0 @@ - interface APIResponse { - status: number; - body: any; -} - -export default APIResponse; diff --git a/lib/ip-pools.ts b/lib/ip-pools.ts index 9acd3fb2..c17b6f41 100644 --- a/lib/ip-pools.ts +++ b/lib/ip-pools.ts @@ -11,7 +11,7 @@ import { IpPoolMessageResponse, IpPoolMessageResult, IpPoolUpdateData, -} from './interfaces/IpPools'; +} from './types/IpPools'; export default class IpPoolsClient { request: Request; diff --git a/lib/ips.ts b/lib/ips.ts index 5347a12a..1c54b12a 100644 --- a/lib/ips.ts +++ b/lib/ips.ts @@ -1,5 +1,5 @@ import MgRequest from './request'; -import { IpData, IpsListResponseBody } from './interfaces/Ips'; +import { IpData, IpsListResponseBody } from './types/Ips'; export default class IpsClient { request: MgRequest; diff --git a/lib/lists.ts b/lib/lists.ts index e7a22508..b75aa1dd 100644 --- a/lib/lists.ts +++ b/lib/lists.ts @@ -6,12 +6,12 @@ import { MailingList, ValidationApiResponse, StartValidationResult, - ValidationResult, + ListValidationResult, CancelValidationResult, MailingListResult, MailingListApiResponse -} from './interfaces/lists'; -import { IMailListsMembers } from './interfaces/mailListMembers'; +} from './types/lists'; +import { IMailListsMembers } from './types/mailListMembers'; import NavigationThruPages from './common/NavigationThruPages'; export default class ListsClient @@ -27,14 +27,14 @@ export default class ListsClient this.members = members; } - private parseValidationResult(status: number, data: ValidationApiResponse): ValidationResult { + private parseValidationResult(status: number, data: ValidationApiResponse): ListValidationResult { return { status, validationResult: { ...data, created_at: new Date(data.created_at * 1000) // add millisecond to Unix timestamp } - } as ValidationResult; + } as ListValidationResult; } protected parseList(response: MailingListApiResponse): MailingListResult { @@ -80,7 +80,7 @@ export default class ListsClient }) as StartValidationResult); } - validationResult(mailListAddress: string): Promise { + validationResult(mailListAddress: string): Promise { return this.request.get(`${this.baseRoute}/${mailListAddress}/validate`) .then( (response) => this.parseValidationResult( diff --git a/lib/mailListMembers.ts b/lib/mailListMembers.ts index aee91a8c..beac4169 100644 --- a/lib/mailListMembers.ts +++ b/lib/mailListMembers.ts @@ -12,7 +12,7 @@ import { NewMultipleMembersResponse, MailListMembersResult, MailListMembersResponse -} from './interfaces/mailListMembers'; +} from './types/mailListMembers'; import NavigationThruPages from './common/NavigationThruPages'; export default class MailListsMembers diff --git a/lib/messages.ts b/lib/messages.ts index 92a57c22..de2d8642 100644 --- a/lib/messages.ts +++ b/lib/messages.ts @@ -1,10 +1,10 @@ import APIError from './error'; -import APIErrorOptions from './interfaces/APIErrorOptions'; +import { APIErrorOptions } from './types/APIErrorOptions'; import { MailgunMessageData, MessagesSendAPIResponse, MessagesSendResult -} from './interfaces/Messages'; +} from './types/Messages'; import Request from './request'; export default class MessagesClient { diff --git a/lib/multipleValidation.ts b/lib/multipleValidation.ts index 3f54290c..be4f62d9 100644 --- a/lib/multipleValidation.ts +++ b/lib/multipleValidation.ts @@ -1,5 +1,5 @@ import NavigationThruPages from './common/NavigationThruPages'; -import APIResponse from './interfaces/ApiResponse'; +import { APIResponse } from './types/ApiResponse'; import { CanceledMultipleValidationJob, CreatedMultipleValidationJob, @@ -12,7 +12,7 @@ import { MultipleValidationJobResult, MultipleValidationJobsListQuery } - from './interfaces/MultipleValidation'; + from './types/MultipleValidation'; import Request from './request'; export class MultipleValidationJob implements MultipleValidationJobResult { diff --git a/lib/request.ts b/lib/request.ts index 6fc9ccb9..b2c76219 100644 --- a/lib/request.ts +++ b/lib/request.ts @@ -3,12 +3,12 @@ import urljoin from 'url-join'; import axios, { AxiosError, AxiosResponse } from 'axios'; import * as NodeFormData from 'form-data'; import APIError from './error'; -import { OnCallEmptyHeaders, OnCallRequestOptions, RequestOptions } from './interfaces/RequestOptions'; -import APIErrorOptions from './interfaces/APIErrorOptions'; -import { InputFormData } from './interfaces/IFormData'; -import APIResponse from './interfaces/ApiResponse'; +import { OnCallEmptyHeaders, OnCallRequestOptions, RequestOptions } from './types/RequestOptions'; +import { APIErrorOptions } from './types/APIErrorOptions'; +import { InputFormData } from './types/IFormData'; +import { APIResponse } from './types/ApiResponse'; import FormDataBuilder from './formDataBuilder'; -import { IpPoolDeleteData } from './interfaces/IpPools'; +import { IpPoolDeleteData } from './types/IpPools'; class Request { private username: string; diff --git a/lib/routes.ts b/lib/routes.ts index b181252d..58bf27bc 100644 --- a/lib/routes.ts +++ b/lib/routes.ts @@ -1,6 +1,6 @@ import { CreateUpdateRouteData, DestroyRouteResponse, Route, RoutesListQuery, UpdateRouteResponse -} from './interfaces/routes'; +} from './types/routes'; import Request from './request'; export default class RoutesClient { diff --git a/lib/stats.ts b/lib/stats.ts index ff4626ba..3bf41f17 100644 --- a/lib/stats.ts +++ b/lib/stats.ts @@ -1,6 +1,6 @@ import urljoin from 'url-join'; import Request from './request'; -import { StatsQuery, StatsOptions, Stat } from './interfaces/StatsOptions'; +import { StatsQuery, StatsOptions, Stat } from './types/StatsOptions'; class Stats { start: Date; diff --git a/lib/suppressions.ts b/lib/suppressions.ts index 48ee8893..fcab11da 100644 --- a/lib/suppressions.ts +++ b/lib/suppressions.ts @@ -14,13 +14,13 @@ import { SuppressionListResponse, SuppressionModels, SuppressionResponse, -} from './interfaces/Suppressions/Suppressions'; +} from './types/Suppressions/Suppressions'; import APIError from './error'; -import APIErrorOptions from './interfaces/APIErrorOptions'; -import { IBounce, BounceData } from './interfaces/Suppressions/Bounce'; -import { IComplaint, ComplaintData } from './interfaces/Suppressions/Complaint'; -import { IUnsubscribe, UnsubscribeData } from './interfaces/Suppressions/Unsubscribe'; -import { IWhiteList, WhiteListData } from './interfaces/Suppressions/WhiteList'; +import { APIErrorOptions } from './types/APIErrorOptions'; +import { IBounce, BounceData } from './types/Suppressions/Bounce'; +import { IComplaint, ComplaintData } from './types/Suppressions/Complaint'; +import { IUnsubscribe, UnsubscribeData } from './types/Suppressions/Unsubscribe'; +import { IWhiteList, WhiteListData } from './types/Suppressions/WhiteList'; import NavigationThruPages from './common/NavigationThruPages'; const createOptions = { diff --git a/lib/interfaces/APIErrorOptions.ts b/lib/types/APIErrorOptions.ts similarity index 68% rename from lib/interfaces/APIErrorOptions.ts rename to lib/types/APIErrorOptions.ts index cd540915..11450665 100644 --- a/lib/interfaces/APIErrorOptions.ts +++ b/lib/types/APIErrorOptions.ts @@ -1,4 +1,4 @@ -interface APIErrorOptions { +export interface APIErrorOptions { headers: { [key: string]: any }; status: number | string; message: string; @@ -6,5 +6,3 @@ interface APIErrorOptions { url: string; statusText: string; } - -export default APIErrorOptions; diff --git a/lib/types/ApiResponse.ts b/lib/types/ApiResponse.ts new file mode 100644 index 00000000..750c879b --- /dev/null +++ b/lib/types/ApiResponse.ts @@ -0,0 +1,4 @@ +export interface APIResponse { + status: number; + body: any; +} diff --git a/lib/interfaces/DomainCredentials.ts b/lib/types/DomainCredentials.ts similarity index 100% rename from lib/interfaces/DomainCredentials.ts rename to lib/types/DomainCredentials.ts diff --git a/lib/interfaces/DomainTags.ts b/lib/types/DomainTags.ts similarity index 100% rename from lib/interfaces/DomainTags.ts rename to lib/types/DomainTags.ts diff --git a/lib/interfaces/DomainTemplates.ts b/lib/types/DomainTemplates.ts similarity index 100% rename from lib/interfaces/DomainTemplates.ts rename to lib/types/DomainTemplates.ts diff --git a/lib/interfaces/DomainTracking.ts b/lib/types/DomainTracking.ts similarity index 100% rename from lib/interfaces/DomainTracking.ts rename to lib/types/DomainTracking.ts diff --git a/lib/interfaces/Domains.ts b/lib/types/Domains.ts similarity index 100% rename from lib/interfaces/Domains.ts rename to lib/types/Domains.ts diff --git a/lib/interfaces/Events.ts b/lib/types/Events.ts similarity index 100% rename from lib/interfaces/Events.ts rename to lib/types/Events.ts diff --git a/lib/interfaces/IFormData.ts b/lib/types/IFormData.ts similarity index 100% rename from lib/interfaces/IFormData.ts rename to lib/types/IFormData.ts diff --git a/lib/interfaces/IMailgunClient.ts b/lib/types/IMailgunClient.ts similarity index 100% rename from lib/interfaces/IMailgunClient.ts rename to lib/types/IMailgunClient.ts diff --git a/lib/interfaces/IpPools.ts b/lib/types/IpPools.ts similarity index 100% rename from lib/interfaces/IpPools.ts rename to lib/types/IpPools.ts diff --git a/lib/interfaces/Ips.ts b/lib/types/Ips.ts similarity index 100% rename from lib/interfaces/Ips.ts rename to lib/types/Ips.ts diff --git a/lib/interfaces/Messages.ts b/lib/types/Messages.ts similarity index 100% rename from lib/interfaces/Messages.ts rename to lib/types/Messages.ts diff --git a/lib/interfaces/MultipleValidation.ts b/lib/types/MultipleValidation.ts similarity index 100% rename from lib/interfaces/MultipleValidation.ts rename to lib/types/MultipleValidation.ts diff --git a/lib/interfaces/NavigationThruPages.ts b/lib/types/NavigationThruPages.ts similarity index 100% rename from lib/interfaces/NavigationThruPages.ts rename to lib/types/NavigationThruPages.ts diff --git a/lib/interfaces/Options.ts b/lib/types/Options.ts similarity index 73% rename from lib/interfaces/Options.ts rename to lib/types/Options.ts index 68fd3112..47e312ff 100644 --- a/lib/interfaces/Options.ts +++ b/lib/types/Options.ts @@ -1,10 +1,8 @@ /* eslint-disable camelcase */ - interface Options { +export interface Options { username: string; key: string; url?: string; public_key?: string; timeout?: number; } - -export default Options; diff --git a/lib/interfaces/RequestOptions.ts b/lib/types/RequestOptions.ts similarity index 79% rename from lib/interfaces/RequestOptions.ts rename to lib/types/RequestOptions.ts index b0160659..f85fee0a 100644 --- a/lib/interfaces/RequestOptions.ts +++ b/lib/types/RequestOptions.ts @@ -1,5 +1,5 @@ -import { AxiosRequestHeaders } from 'axios' -import Options from './Options'; +import { AxiosRequestHeaders } from 'axios'; +import { Options } from './Options'; export interface OnCallEmptyHeaders { [key: string]: undefined; diff --git a/lib/interfaces/StatsOptions.ts b/lib/types/StatsOptions.ts similarity index 100% rename from lib/interfaces/StatsOptions.ts rename to lib/types/StatsOptions.ts diff --git a/lib/interfaces/Suppressions/Bounce.ts b/lib/types/Suppressions/Bounce.ts similarity index 100% rename from lib/interfaces/Suppressions/Bounce.ts rename to lib/types/Suppressions/Bounce.ts diff --git a/lib/interfaces/Suppressions/Complaint.ts b/lib/types/Suppressions/Complaint.ts similarity index 100% rename from lib/interfaces/Suppressions/Complaint.ts rename to lib/types/Suppressions/Complaint.ts diff --git a/lib/interfaces/Suppressions/Suppressions.ts b/lib/types/Suppressions/Suppressions.ts similarity index 100% rename from lib/interfaces/Suppressions/Suppressions.ts rename to lib/types/Suppressions/Suppressions.ts diff --git a/lib/interfaces/Suppressions/Unsubscribe.ts b/lib/types/Suppressions/Unsubscribe.ts similarity index 100% rename from lib/interfaces/Suppressions/Unsubscribe.ts rename to lib/types/Suppressions/Unsubscribe.ts diff --git a/lib/interfaces/Suppressions/WhiteList.ts b/lib/types/Suppressions/WhiteList.ts similarity index 100% rename from lib/interfaces/Suppressions/WhiteList.ts rename to lib/types/Suppressions/WhiteList.ts diff --git a/lib/types/Suppressions/index.ts b/lib/types/Suppressions/index.ts new file mode 100644 index 00000000..30fc6c44 --- /dev/null +++ b/lib/types/Suppressions/index.ts @@ -0,0 +1,5 @@ +export * from './Bounce'; +export * from './Complaint'; +export * from './Suppressions'; +export * from './Unsubscribe'; +export * from './WhiteList'; diff --git a/lib/interfaces/Validate.ts b/lib/types/Validate.ts similarity index 100% rename from lib/interfaces/Validate.ts rename to lib/types/Validate.ts diff --git a/lib/interfaces/Webhooks.ts b/lib/types/Webhooks.ts similarity index 93% rename from lib/interfaces/Webhooks.ts rename to lib/types/Webhooks.ts index 435464d9..cf9e2023 100644 --- a/lib/interfaces/Webhooks.ts +++ b/lib/types/Webhooks.ts @@ -24,7 +24,7 @@ export type WebhooksQuery = { skip?: number; } -export interface ValidationResponse { +export interface WebhooksValidationResponse { code: number; message: string; } diff --git a/lib/types/index.ts b/lib/types/index.ts new file mode 100644 index 00000000..e488b160 --- /dev/null +++ b/lib/types/index.ts @@ -0,0 +1,24 @@ +export * from './APIErrorOptions'; +export * from './ApiResponse'; +export * from './DomainCredentials'; +export * from './DomainTags'; +export * from './DomainTemplates'; +export * from './DomainTracking'; +export * from './Domains'; +export * from './Events'; +export * from './IFormData'; +export * from './IMailgunClient'; +export * from './IpPools'; +export * from './Ips'; +export * from './Messages'; +export * from './MultipleValidation'; +export * from './NavigationThruPages'; +export * from './Options'; +export * from './RequestOptions'; +export * from './StatsOptions'; +export * from './Suppressions'; +export * from './Validate'; +export * from './Webhooks'; +export * from './lists'; +export * from './mailListMembers'; +export * from './routes'; diff --git a/lib/interfaces/lists.ts b/lib/types/lists.ts similarity index 88% rename from lib/interfaces/lists.ts rename to lib/types/lists.ts index 79ab8a6f..544bc0b2 100644 --- a/lib/interfaces/lists.ts +++ b/lib/types/lists.ts @@ -26,7 +26,7 @@ export interface StartValidationResult { message: string; } -export interface ValidationResponse { +export interface ListValidationResponse { status: string; download_url: { csv: string; @@ -51,13 +51,13 @@ export interface ValidationResponse { } } } -export interface ValidationApiResponse extends ValidationResponse{ +export interface ValidationApiResponse extends ListValidationResponse{ created_at: number; } -export interface ValidationResultData extends ValidationResponse{ +export interface ValidationResultData extends ListValidationResponse{ created_at: Date; } -export interface ValidationResult { +export interface ListValidationResult { status: number; validationResult: ValidationResultData; } diff --git a/lib/interfaces/mailListMembers.ts b/lib/types/mailListMembers.ts similarity index 100% rename from lib/interfaces/mailListMembers.ts rename to lib/types/mailListMembers.ts diff --git a/lib/interfaces/routes.ts b/lib/types/routes.ts similarity index 100% rename from lib/interfaces/routes.ts rename to lib/types/routes.ts diff --git a/lib/validate.ts b/lib/validate.ts index b16ddb44..190bffbf 100644 --- a/lib/validate.ts +++ b/lib/validate.ts @@ -1,5 +1,5 @@ -import { IMultipleValidationClient } from './interfaces/MultipleValidation'; -import { ValidationResult, ValidationResponse, ValidationQuery } from './interfaces/Validate'; +import { IMultipleValidationClient } from './types/MultipleValidation'; +import { ValidationResult, ValidationResponse, ValidationQuery } from './types/Validate'; import Request from './request'; export default class ValidateClient { diff --git a/lib/webhooks.ts b/lib/webhooks.ts index 187e5a1a..c99d7d86 100644 --- a/lib/webhooks.ts +++ b/lib/webhooks.ts @@ -1,12 +1,12 @@ import urljoin from 'url-join'; import { - ValidationResponse, + WebhooksValidationResponse, WebhookList, WebhookResponse, WebhooksIds, WebhooksQuery -} from './interfaces/Webhooks'; +} from './types/Webhooks'; import Request from './request'; class Webhook { @@ -45,7 +45,10 @@ export default class WebhookClient { _parseWebhookTest(response: { body: { code: number, message: string } }) : {code: number, message:string} { - return { code: response.body.code, message: response.body.message } as ValidationResponse; + return { + code: response.body.code, + message: response.body.message + } as WebhooksValidationResponse; } list(domain: string, query: WebhooksQuery): Promise { @@ -61,7 +64,7 @@ export default class WebhookClient { create(domain: string, id: string, url: string, - test = false): Promise { + test = false): Promise { if (test) { return this.request.putWithFD(urljoin('/v3/domains', domain, 'webhooks', id, 'test'), { url }) .then(this._parseWebhookTest); diff --git a/test/client.test.ts b/test/client.test.ts index d3870bb4..4c52fa5c 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -12,7 +12,7 @@ import MessagesClient from '../lib/messages'; import RoutesClient from '../lib/routes'; import ValidateClient from '../lib/validate'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { InputFormData } from '../lib/types/IFormData'; import StatsClient from '../lib/stats'; import ListsClient from '../lib/lists'; import IpPoolsClient from '../lib/ip-pools'; diff --git a/test/domains.test.ts b/test/domains.test.ts index dc8e5a4f..f52790a7 100644 --- a/test/domains.test.ts +++ b/test/domains.test.ts @@ -4,8 +4,8 @@ import nock from 'nock'; import { expect } from 'chai'; import Request from '../lib/request'; import DomainClient, { Domain } from '../lib/domains'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; import DomainCredentialsClient from '../lib/domainsCredentials'; import { ConnectionSettings, @@ -13,10 +13,10 @@ import { UpdatedConnectionSettings, UpdatedDKIMAuthority, UpdatedDKIMSelectorResponse, UpdatedWebPrefixResponse -} from '../lib/interfaces/Domains'; +} from '../lib/types/Domains'; import DomainTemplatesClient from '../lib/domainsTemplates'; import DomainTagsClient from '../lib/domainsTags'; -import APIResponse from '../lib/interfaces/ApiResponse'; +import { APIResponse } from '../lib/types/ApiResponse'; // TODO: fix types describe('DomainClient', function () { diff --git a/test/domainsCredentials.test.ts b/test/domainsCredentials.test.ts index 4a002f79..60a33f2b 100644 --- a/test/domainsCredentials.test.ts +++ b/test/domainsCredentials.test.ts @@ -2,10 +2,10 @@ import formData from 'form-data'; import nock from 'nock'; import Request from '../lib/request'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; import DomainCredentialsClient from '../lib/domainsCredentials'; -import { DomainCredentialsList, DomainCredentialsResult } from '../lib/interfaces/DomainCredentials'; +import { DomainCredentialsList, DomainCredentialsResult } from '../lib/types/DomainCredentials'; // TODO: fix types describe('DomainsCredentialsClient', function () { diff --git a/test/domainsTags.test.ts b/test/domainsTags.test.ts index 5ab192ad..50043393 100644 --- a/test/domainsTags.test.ts +++ b/test/domainsTags.test.ts @@ -2,8 +2,8 @@ import formData from 'form-data'; import nock from 'nock'; import Request from '../lib/request'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; import DomainsTagsClient, { DomainTagStatistic } from '../lib/domainsTags'; import { DomainTagCountriesAggregation, @@ -12,7 +12,7 @@ import { DomainTagsItem, DomainTagsList, DomainTagsMessageRes -} from '../lib/interfaces/DomainTags'; +} from '../lib/types/DomainTags'; describe('DomainsTagsClient', function () { let client: DomainsTagsClient; diff --git a/test/domainsTemplates.test.ts b/test/domainsTemplates.test.ts index 6446e48e..2a317476 100644 --- a/test/domainsTemplates.test.ts +++ b/test/domainsTemplates.test.ts @@ -3,10 +3,10 @@ import formData from 'form-data'; import nock from 'nock'; import Request from '../lib/request'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; import DomainTemplatesClient from '../lib/domainsTemplates'; -import { DomainTemplateUpdateVersionData, DomainTemplateVersionData } from '../lib/interfaces/DomainTemplates'; +import { DomainTemplateUpdateVersionData, DomainTemplateVersionData } from '../lib/types/DomainTemplates'; // TODO: fix types describe('DomainsTemplatesClient', function () { diff --git a/test/error.test.ts b/test/error.test.ts index b9aadb2a..579970d8 100644 --- a/test/error.test.ts +++ b/test/error.test.ts @@ -1,5 +1,5 @@ import APIError from '../lib/error'; -import APIErrorOptions from '../lib/interfaces/APIErrorOptions'; +import { APIErrorOptions } from '../lib/types/APIErrorOptions'; describe('APIError', function () { let error; diff --git a/test/events.test.ts b/test/events.test.ts index 975b9517..00dd1e01 100644 --- a/test/events.test.ts +++ b/test/events.test.ts @@ -4,9 +4,9 @@ import nock from 'nock'; import formData from 'form-data'; import EventClient from '../lib/events'; import MgRequest from '../lib/request'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; -import { EventsList, EventsResponse } from '../lib/interfaces/Events'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; +import { EventsList, EventsResponse } from '../lib/types/Events'; describe('EventsClient', function () { let client: EventClient; diff --git a/test/ip-pools.test.ts b/test/ip-pools.test.ts index bda0cdf1..b7421cb5 100644 --- a/test/ip-pools.test.ts +++ b/test/ip-pools.test.ts @@ -1,9 +1,9 @@ import nock from 'nock'; import formData from 'form-data'; import Request from '../lib/request'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; +import { RequestOptions } from '../lib/types/RequestOptions'; import IpPoolsClient from '../lib/ip-pools'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { InputFormData } from '../lib/types/IFormData'; describe('IpPoolsClient', function () { let client: IpPoolsClient; diff --git a/test/ips.test.ts b/test/ips.test.ts index d5b89423..6687aced 100644 --- a/test/ips.test.ts +++ b/test/ips.test.ts @@ -3,11 +3,11 @@ import nock from 'nock'; import formData from 'form-data'; import Request from '../lib/request'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; +import { RequestOptions } from '../lib/types/RequestOptions'; import IpsClient from '../lib/ips'; -import { IpData, IpsListResponseBody } from '../lib/interfaces/Ips'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { IpData, IpsListResponseBody } from '../lib/types/Ips'; +import { InputFormData } from '../lib/types/IFormData'; // TODO: fix types describe('DomainClient', function () { diff --git a/test/lists.test.ts b/test/lists.test.ts index dd5aa23f..244c6dfe 100644 --- a/test/lists.test.ts +++ b/test/lists.test.ts @@ -3,15 +3,15 @@ import formData from 'form-data'; import Request from '../lib/request'; import ListsClient from '../lib/lists'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; +import { RequestOptions } from '../lib/types/RequestOptions'; import MailListMembers from '../lib/mailListMembers'; import { CancelValidationResult, MailingList, StartValidationResult, - ValidationResult -} from '../lib/interfaces/lists'; -import { InputFormData } from '../lib/interfaces/IFormData'; + ListValidationResult +} from '../lib/types/lists'; +import { InputFormData } from '../lib/types/IFormData'; describe('ListsClient', function () { let client: any; @@ -179,7 +179,7 @@ describe('ListsClient', function () { } }); - return client.validationResult('test@example.com').then(function (data: ValidationResult) { + return client.validationResult('test@example.com').then(function (data: ListValidationResult) { data.should.eql({ status: 200, validationResult: { diff --git a/test/mailListMembers.test.ts b/test/mailListMembers.test.ts index 69240a13..ed2a21e6 100644 --- a/test/mailListMembers.test.ts +++ b/test/mailListMembers.test.ts @@ -1,10 +1,10 @@ import nock from 'nock'; import formData from 'form-data'; import Request from '../lib/request'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; +import { RequestOptions } from '../lib/types/RequestOptions'; import MailListMembers from '../lib/mailListMembers'; -import { DeletedMember, MailListMember, NewMultipleMembersResponse } from '../lib/interfaces/mailListMembers'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { DeletedMember, MailListMember, NewMultipleMembersResponse } from '../lib/types/mailListMembers'; +import { InputFormData } from '../lib/types/IFormData'; describe('mailListsMembersClient', function () { let client: any; diff --git a/test/messageAttachment.test.ts b/test/messageAttachment.test.ts index 9211d04e..33171078 100644 --- a/test/messageAttachment.test.ts +++ b/test/messageAttachment.test.ts @@ -5,8 +5,8 @@ import formData from 'form-data'; import Request from '../lib/request'; import MessagesClient from '../lib/messages'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; const mailgunLogo = fs.createReadStream(`${__dirname}/img/mailgun.png`); diff --git a/test/messages.test.ts b/test/messages.test.ts index 94b2fdec..1224a305 100644 --- a/test/messages.test.ts +++ b/test/messages.test.ts @@ -7,9 +7,9 @@ import spies from 'chai-spies'; import Request from '../lib/request'; import MessagesClient from '../lib/messages'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; -import { MessagesSendResult } from '../lib/interfaces/Messages'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; +import { MessagesSendResult } from '../lib/types/Messages'; chai.use(spies); const expect = chai.expect; diff --git a/test/multipleValidation.test.ts b/test/multipleValidation.test.ts index 344fc3ec..1bc1e324 100644 --- a/test/multipleValidation.test.ts +++ b/test/multipleValidation.test.ts @@ -4,14 +4,14 @@ import path from 'path'; import nock from 'nock'; import Request from '../lib/request'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; import MultipleValidationClient, { MultipleValidationJob } from '../lib/multipleValidation'; import { CanceledMultipleValidationJob, CreatedMultipleValidationJob, MultipleValidationJobsListResult -} from '../lib/interfaces/MultipleValidation'; +} from '../lib/types/MultipleValidation'; const filepath = path.resolve(__dirname, './data/emailsValidation1.csv'); diff --git a/test/request.test.ts b/test/request.test.ts index f6c4401a..666f0ddd 100644 --- a/test/request.test.ts +++ b/test/request.test.ts @@ -5,10 +5,10 @@ import base64 from 'base-64'; import nock from 'nock'; import { expect } from 'chai'; import Request from '../lib/request'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; +import { RequestOptions } from '../lib/types/RequestOptions'; import APIError from '../lib/error'; -import APIResponse from '../lib/interfaces/ApiResponse'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { APIResponse } from '../lib/types/ApiResponse'; +import { InputFormData } from '../lib/types/IFormData'; describe('Request', function () { let headers: { [key: string]: string }; diff --git a/test/routes.test.ts b/test/routes.test.ts index 961fa93d..4a7ffb64 100644 --- a/test/routes.test.ts +++ b/test/routes.test.ts @@ -3,8 +3,8 @@ import formData from 'form-data'; import nock from 'nock'; import Request from '../lib/request'; import RoutesClient from '../lib/routes'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; interface Data { actions: string[], diff --git a/test/stats.test.ts b/test/stats.test.ts index 31fbbfe1..362ea448 100644 --- a/test/stats.test.ts +++ b/test/stats.test.ts @@ -3,9 +3,9 @@ import formData from 'form-data'; import nock from 'nock'; import Request from '../lib/request'; import StatsClient from '../lib/stats'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { StatsOptions, StatsQuery } from '../lib/interfaces/StatsOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { StatsOptions, StatsQuery } from '../lib/types/StatsOptions'; +import { InputFormData } from '../lib/types/IFormData'; describe('StatsClient', function () { let client: StatsClient; diff --git a/test/suppressions.test.ts b/test/suppressions.test.ts index 209c9c32..2b4742b8 100644 --- a/test/suppressions.test.ts +++ b/test/suppressions.test.ts @@ -4,9 +4,9 @@ import nock from 'nock'; import Request from '../lib/request'; import SuppressionClient from '../lib/suppressions'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; -import { WhiteListData } from '../lib/interfaces/Suppressions/WhiteList'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; +import { WhiteListData } from '../lib/types/Suppressions/WhiteList'; chai.should(); diff --git a/test/validate.test.ts b/test/validate.test.ts index f90217f6..03af3f52 100644 --- a/test/validate.test.ts +++ b/test/validate.test.ts @@ -3,8 +3,8 @@ import formData from 'form-data'; import nock from 'nock'; import Request from '../lib/request'; import ValidateClient from '../lib/validate'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; import MultipleValidationClient from '../lib/multipleValidation'; describe('ValidateClient', function () { diff --git a/test/webhooks.test.ts b/test/webhooks.test.ts index b23efa6f..dfab2d92 100644 --- a/test/webhooks.test.ts +++ b/test/webhooks.test.ts @@ -2,8 +2,8 @@ import formData from 'form-data'; import nock from 'nock'; import Request from '../lib/request'; import WebhookClient from '../lib/webhooks'; -import { RequestOptions } from '../lib/interfaces/RequestOptions'; -import { InputFormData } from '../lib/interfaces/IFormData'; +import { RequestOptions } from '../lib/types/RequestOptions'; +import { InputFormData } from '../lib/types/IFormData'; describe('WebhookClient', function () { let client: any;