delete-domain route added (#267)
This commit is contained in:
@@ -37,6 +37,14 @@ type GetDomainResponse = {
|
||||
type GetDomainResponseSuccess =
|
||||
paths["/v1/domains/{id}"]["get"]["responses"]["200"]["content"]["application/json"];
|
||||
|
||||
type DeleteDomainResponse = {
|
||||
data: DeleteDomainResponseSuccess | null;
|
||||
error: ErrorResponse | null;
|
||||
};
|
||||
|
||||
type DeleteDomainResponseSuccess =
|
||||
paths["/v1/domains/{id}"]["delete"]["responses"]["200"]["content"]["application/json"];
|
||||
|
||||
export class Domains {
|
||||
constructor(private readonly usesend: UseSend) {
|
||||
this.usesend = usesend;
|
||||
@@ -50,7 +58,7 @@ export class Domains {
|
||||
async create(payload: CreateDomainPayload): Promise<CreateDomainResponse> {
|
||||
const data = await this.usesend.post<CreateDomainResponseSuccess>(
|
||||
"/domains",
|
||||
payload
|
||||
payload,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
@@ -58,14 +66,22 @@ export class Domains {
|
||||
async verify(id: number): Promise<VerifyDomainResponse> {
|
||||
const data = await this.usesend.put<VerifyDomainResponseSuccess>(
|
||||
`/domains/${id}/verify`,
|
||||
{}
|
||||
{},
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async get(id: number): Promise<GetDomainResponse> {
|
||||
const data = await this.usesend.get<GetDomainResponseSuccess>(
|
||||
`/domains/${id}`
|
||||
`/domains/${id}`,
|
||||
);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<DeleteDomainResponse> {
|
||||
const data = await this.usesend.delete<DeleteDomainResponseSuccess>(
|
||||
`/domains/${id}`,
|
||||
);
|
||||
|
||||
return data;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ErrorResponse } from "../types";
|
||||
import { Contacts } from "./contact";
|
||||
import { Emails } from "./email";
|
||||
import { Domains } from "./domain";
|
||||
|
||||
const defaultBaseUrl = "https://app.usesend.com";
|
||||
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
||||
@@ -15,12 +16,13 @@ export class UseSend {
|
||||
|
||||
// readonly domains = new Domains(this);
|
||||
readonly emails = new Emails(this);
|
||||
readonly domains = new Domains(this);
|
||||
readonly contacts = new Contacts(this);
|
||||
url = baseUrl;
|
||||
|
||||
constructor(
|
||||
readonly key?: string,
|
||||
url?: string
|
||||
url?: string,
|
||||
) {
|
||||
if (!key) {
|
||||
if (typeof process !== "undefined" && process.env) {
|
||||
@@ -29,7 +31,7 @@ export class UseSend {
|
||||
|
||||
if (!this.key) {
|
||||
throw new Error(
|
||||
'Missing API key. Pass it to the constructor `new UseSend("us_123")`'
|
||||
'Missing API key. Pass it to the constructor `new UseSend("us_123")`',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -46,7 +48,7 @@ export class UseSend {
|
||||
|
||||
async fetchRequest<T>(
|
||||
path: string,
|
||||
options = {}
|
||||
options = {},
|
||||
): Promise<{ data: T | null; error: ErrorResponse | null }> {
|
||||
const response = await fetch(`${this.url}${path}`, options);
|
||||
const defaultError = {
|
||||
|
||||
Reference in New Issue
Block a user