@tozielinski/next-brevo-api-helper 1.0.0 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +67 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # next-brevo-api-helper
2
2
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
+ [![npm version](https://img.shields.io/npm/v/%40tozielinski%2Fnext-brevo-api-helper)](https://www.npmjs.com/package/@tozielinski/next-upstash-nonce)
3
4
 
4
5
  ## Using the Brevo API for create, update and delete contacts, folders and lists and send mails via the API
5
6
 
@@ -7,4 +8,69 @@
7
8
  ### Install the package:
8
9
  ```bash
9
10
  npm install @tozielinski/next-brevo-api-helper
10
- ```
11
+ ```
12
+ ### Create an API Key in Brevo: and add it to your Next.js environment variables:
13
+ ```
14
+ BREVO_API_KEY=your-brevo-api-key
15
+ ```
16
+ https://www.brevo.com/api-keys
17
+ ### Create a ServerAction, and use it in your Next.js page:
18
+ ```tsx
19
+ 'use server'
20
+
21
+ import {BrevoClient, BrevoEmailRecipient, BrevoSendEmailRequest} from "@tozielinski/next-brevo-api-helper";
22
+
23
+ const brevoClient = new BrevoClient();
24
+
25
+ const mail: BrevoSendEmailRequest = {
26
+ to:
27
+ [{
28
+ email: string
29
+ }]
30
+ ,
31
+ // sender: {
32
+ // email: string
33
+ // } satisfies BrevoEmailRecipient,
34
+ // cc?: BrevoEmailRecipient[];
35
+ // bcc?: BrevoEmailRecipient[];
36
+ // replyTo?: {
37
+ // email: string,
38
+ // name?: string,
39
+ // } satisfies BrevoEmailRecipient,
40
+ // subject: string,
41
+ // htmlContent: string,
42
+ // textContent: string,
43
+ // textContent: string,
44
+ // templateId?: number;
45
+ // params?: Record<string, string | number | boolean>;
46
+ // headers?: Record<string, string>;
47
+ // attachment?: {
48
+ // url?: string;
49
+ // content?: string; // Base64 encoded
50
+ // name?: string;
51
+ // }[];
52
+ // tags?: string[];
53
+ };
54
+
55
+ export async function sendMail() {
56
+ return brevoClient.sendEmail(mail);
57
+ }
58
+
59
+ export async function getFolders(apiKey?:string) {
60
+ const brevoClient = new BrevoClient();
61
+ return brevoClient.getFolders();
62
+ }
63
+
64
+ export async function getFolderDetails(folderId: number, apiKey?:string) {
65
+ const brevoClient = new BrevoClient();
66
+ return brevoClient.getFolderDetails({id: folderId});
67
+ }
68
+
69
+ export async function createFolder(name: string) {
70
+ return brevoClient.createFolder({name: name});
71
+ }
72
+
73
+ export async function deleteFolder(id: number) {
74
+ return brevoClient.deleteFolder({id: id});
75
+ }
76
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tozielinski/next-brevo-api-helper",
3
- "version": "1.0.0",
3
+ "version": "1.0.4",
4
4
  "description": "Lightweight helper to use Brevo to send mails via the Brevo API and maintain all",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",