feat(medusa-plugin-mailchimp): Migrate to TS + add update endpoint (#4040)

* - Refactored the .js files to .ts files
- Added typing
- Used 'WrapHandler' util instead of specific middleware in plugin
- Added additional PUT method to the /mailchimp/subscribe endpoint.
- Updated documentation where relevant.

* Added changeset

* Updated yarn.lock

* Used camelcase for method args in services/mailchimp.ts

---------

Co-authored-by: Tom Rupke <tom@adapptive.nl>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2023-05-23 13:33:56 +02:00
1 parent 5c01b4e6b6
commit ddc90db530
19 files changed
+401 -158

No files matched your search

+22 -23
View File
@@ -22,32 +22,31 @@ Manage newsletter subscriptions in your commerce application with Mailchimp.
1\. Run the following command in the directory of the Medusa backend:
```bash
npm install medusa-plugin-mailchimp
```
```bash
npm install medusa-plugin-mailchimp
```
2\. Set the following environment variables in `.env`:
```bash
MAILCHIMP_API_KEY=<YOUR_API_KEY>
MAILCHIMP_NEWSLETTER_LIST_ID=<YOUR_NEWSLETTER_LIST_ID>
```
```bash
MAILCHIMP_API_KEY=<YOUR_API_KEY>
MAILCHIMP_NEWSLETTER_LIST_ID=<YOUR_NEWSLETTER_LIST_ID>
```
3\. In `medusa-config.js` add the following at the end of the `plugins` array:
```js
const plugins = [
// ...,
{
resolve: `medusa-plugin-mailchimp`,
options: {
api_key: process.env.MAILCHIMP_API_KEY,
newsletter_list_id:
process.env.MAILCHIMP_NEWSLETTER_LIST_ID,
},
```js
const plugins = [
// ...,
{
resolve: `medusa-plugin-mailchimp`,
options: {
api_key: process.env.MAILCHIMP_API_KEY,
newsletter_list_id: process.env.MAILCHIMP_NEWSLETTER_LIST_ID,
},
]
```
},
]
```
---
@@ -55,11 +54,11 @@ Manage newsletter subscriptions in your commerce application with Mailchimp.
1\. Run the following command in the directory of the Medusa backend to run the backend:
```bash
npm run start
```
```bash
npm run start
```
2\. Use the `/mailchimp/subscribe` endpoint or the `MailchimpService` to subscribe to the newsletter.
2\. Use the POST or PUT `/mailchimp/subscribe` endpoint or the `MailchimpService` to subscribe to the newsletter.
---