Constructs API request paths for inbox resources using ID or email selectors. Use this when interacting with email service APIs to ensure correctly formatted endpoints.
// Source: https://github.com/resend/resend-node | License: MIT | Copyright 2023 Plus Five Five, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import type { InboxSelector } from './interfaces/inbox';
export function buildInboxPath(selector: InboxSelector): string | undefined {
const idOrEmail = selector?.inboxId ?? selector?.emailAddress;
return idOrEmail ? `/inboxes/${encodeURIComponent(idOrEmail)}` : undefined;
}
export const missingInboxError = () => ({
data: null,
headers: null,
error: {
message: 'Missing `inboxId` or `emailAddress` field.',
statusCode: null,
name: 'missing_required_field' as const,
},
});
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key