Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose types #300

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/client.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions lib/common/NavigationThruPages.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import urljoin from 'url-join';
import APIError from '../error';
import APIErrorOptions from '../interfaces/APIErrorOptions';
import { APIErrorOptions } from '../types/APIErrorOptions';
import {
PagesListAccumulator,
ParsedPage,
ParsedPagesList,
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 <T> {
Expand Down
14 changes: 7 additions & 7 deletions lib/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions lib/domainsCredentials.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import urljoin from 'url-join';
import APIResponse from './interfaces/ApiResponse';
import { APIResponse } from './types/ApiResponse';
import Request from './request';

import {
Expand All @@ -12,7 +12,7 @@ import {
DomainCredentialsResult,
IDomainCredentials,
UpdateDomainCredentialsData
} from './interfaces/DomainCredentials';
} from './types/DomainCredentials';

export default class DomainCredentialsClient implements IDomainCredentials {
baseRoute: string;
Expand Down
4 changes: 2 additions & 2 deletions lib/domainsTags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import urljoin from 'url-join';
import APIResponse from './interfaces/ApiResponse';
import { APIResponse } from './types/ApiResponse';
import Request from './request';

import {
Expand All @@ -22,7 +22,7 @@ import {
DomainTagStatisticResult,
IDomainTagsClient,
Resolution
} from './interfaces/DomainTags';
} from './types/DomainTags';
import NavigationThruPages from './common/NavigationThruPages';

export class DomainTag implements DomainTagsItem {
Expand Down
2 changes: 1 addition & 1 deletion lib/domainsTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
TemplateVersion,
UpdateOrDeleteDomainTemplateAPIResponse,
UpdateOrDeleteDomainTemplateResult
} from './interfaces/DomainTemplates';
} from './types/DomainTemplates';
import NavigationThruPages from './common/NavigationThruPages';

export class DomainTemplateItem implements DomainTemplate {
Expand Down
2 changes: 1 addition & 1 deletion lib/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import APIErrorOptions from './interfaces/APIErrorOptions';
import { APIErrorOptions } from './types/APIErrorOptions';

export default class APIError extends Error {
status: number | string;
Expand Down
2 changes: 1 addition & 1 deletion lib/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
EventsList,
EventsQuery,
EventsResponse,
} from './interfaces/Events';
} from './types/Events';

import Request from './request';

Expand Down
2 changes: 1 addition & 1 deletion lib/formDataBuilder.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 3 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -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; }
Expand Down
6 changes: 0 additions & 6 deletions lib/interfaces/ApiResponse.ts

This file was deleted.

2 changes: 1 addition & 1 deletion lib/ip-pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
IpPoolMessageResponse,
IpPoolMessageResult,
IpPoolUpdateData,
} from './interfaces/IpPools';
} from './types/IpPools';

export default class IpPoolsClient {
request: Request;
Expand Down
2 changes: 1 addition & 1 deletion lib/ips.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
12 changes: 6 additions & 6 deletions lib/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -80,7 +80,7 @@ export default class ListsClient
}) as StartValidationResult);
}

validationResult(mailListAddress: string): Promise<ValidationResult> {
validationResult(mailListAddress: string): Promise<ListValidationResult> {
return this.request.get(`${this.baseRoute}/${mailListAddress}/validate`)
.then(
(response) => this.parseValidationResult(
Expand Down
2 changes: 1 addition & 1 deletion lib/mailListMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
NewMultipleMembersResponse,
MailListMembersResult,
MailListMembersResponse
} from './interfaces/mailListMembers';
} from './types/mailListMembers';
import NavigationThruPages from './common/NavigationThruPages';

export default class MailListsMembers
Expand Down
4 changes: 2 additions & 2 deletions lib/messages.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions lib/multipleValidation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NavigationThruPages from './common/NavigationThruPages';
import APIResponse from './interfaces/ApiResponse';
import { APIResponse } from './types/ApiResponse';
import {
CanceledMultipleValidationJob,
CreatedMultipleValidationJob,
Expand All @@ -12,7 +12,7 @@ import {
MultipleValidationJobResult,
MultipleValidationJobsListQuery
}
from './interfaces/MultipleValidation';
from './types/MultipleValidation';
import Request from './request';

export class MultipleValidationJob implements MultipleValidationJobResult {
Expand Down
10 changes: 5 additions & 5 deletions lib/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
CreateUpdateRouteData, DestroyRouteResponse, Route, RoutesListQuery, UpdateRouteResponse
} from './interfaces/routes';
} from './types/routes';
import Request from './request';

export default class RoutesClient {
Expand Down
2 changes: 1 addition & 1 deletion lib/stats.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
12 changes: 6 additions & 6 deletions lib/suppressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
interface APIErrorOptions {
export interface APIErrorOptions {
headers: { [key: string]: any };
status: number | string;
message: string;
body: any;
url: string;
statusText: string;
}

export default APIErrorOptions;
4 changes: 4 additions & 0 deletions lib/types/ApiResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface APIResponse {
status: number;
body: any;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions lib/interfaces/Options.ts → lib/types/Options.ts
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions lib/types/Suppressions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './Bounce';
export * from './Complaint';
export * from './Suppressions';
export * from './Unsubscribe';
export * from './WhiteList';
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/interfaces/Webhooks.ts → lib/types/Webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type WebhooksQuery = {
skip?: number;
}

export interface ValidationResponse {
export interface WebhooksValidationResponse {
code: number;
message: string;
}
Expand Down
24 changes: 24 additions & 0 deletions lib/types/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Loading