import { removeObjectEmptyFields } from "https://deno.land/x/windmill_helpers@v1.0.0/mod.ts";
/**
* Find more information about the parameters at
* https://mailchimp.com/developer/marketing/api/campaigns/add-campaign/
*/
type Mailchimp = {
api_key: string;
server: string;
};
export async function main(
auth: Mailchimp,
type: "regular" | "plaintext" | "rss" | "variate",
content_type: "template" | "multichannel" = "template",
rss_opts?: Record<string, any>,
recipients?: Record<string, any>,
variate_settings?: Record<string, any>,
settings?: Record<string, any>,
tracking?: Record<string, any>,
social_card?: Record<string, any>,
) {
const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns`;
const body = {
type,
content_type,
rss_opts,
recipients,
variate_settings,
settings,
tracking,
social_card,
};
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${auth.api_key}`,
},
body: JSON.stringify(removeObjectEmptyFields(body)),
});
if (!response.ok) {
throw Error(await response.text());
}
return await response.json();
}
Submitted by admin 502 days ago
import { removeObjectEmptyFields } from 'https://deno.land/x/windmill_helpers@v1.0.0/mod.ts'
/**
* Find more information about the parameters at
* https://mailchimp.com/developer/marketing/api/campaigns/add-campaign/
*/
type Mailchimp = {
api_key: string;
server: string;
};
export async function main(
auth: Mailchimp,
type: 'regular' | 'plaintext' | 'rss' | 'variate',
content_type: 'template' | 'multichannel' = 'template',
rss_opts?: Record<string, any>,
recipients?: Record<string, any>,
variate_settings?: Record<string, any>,
settings?: Record<string, any>,
tracking?: Record<string, any>,
social_card?: Record<string, any>,
) {
const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns`;
const body = {
type,
content_type,
rss_opts,
recipients,
variate_settings,
settings,
tracking,
social_card
}
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${auth.api_key}`,
},
body: JSON.stringify(removeObjectEmptyFields(body)),
});
if(!response.ok) {
throw Error(await response.text())
}
return await response.json();
}
Submitted by admin 506 days ago
import { Resource } from 'https://deno.land/x/windmill@v1.85.0/mod.ts'
import { removeObjectEmptyFields } from 'https://deno.land/x/windmill_helpers@v1.0.0/mod.ts'
/**
* Find more information about the parameters at
* https://mailchimp.com/developer/marketing/api/campaigns/add-campaign/
*/
export async function main(
auth: Resource<'mailchimp'>,
type: 'regular' | 'plaintext' | 'rss' | 'variate',
content_type: 'template' | 'multichannel' = 'template',
rss_opts?: Record<string, any>,
recipients?: Record<string, any>,
variate_settings?: Record<string, any>,
settings?: Record<string, any>,
tracking?: Record<string, any>,
social_card?: Record<string, any>,
) {
const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns`;
const body = {
type,
content_type,
rss_opts,
recipients,
variate_settings,
settings,
tracking,
social_card
}
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${auth.api_key}`,
},
body: JSON.stringify(removeObjectEmptyFields(body)),
});
if(!response.ok) {
throw Error(await response.text())
}
return await response.json();
}
Submitted by adam186 634 days ago
import { Resource } from 'https://deno.land/x/windmill@v1.70.1/mod.ts'
import { removeObjectEmptyFields } from 'https://deno.land/x/windmill_helpers@v1.0.0/mod.ts'
/**
* Find more information about the parameters at
* https://mailchimp.com/developer/marketing/api/campaigns/add-campaign/
*/
export async function main(
auth: Resource<'mailchimp'>,
type: 'regular' | 'plaintext' | 'rss' | 'variate',
content_type: 'template' | 'multichannel' = 'template',
rss_opts?: Record<string, any>,
recipients?: Record<string, any>,
variate_settings?: Record<string, any>,
settings?: Record<string, any>,
tracking?: Record<string, any>,
social_card?: Record<string, any>,
) {
const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns`;
const body = {
type,
content_type,
rss_opts,
recipients,
variate_settings,
settings,
tracking,
social_card
}
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${auth.api_key}`,
},
body: JSON.stringify(removeObjectEmptyFields(body)),
});
if(!response.ok) {
throw Error(await response.text())
}
return await response.json();
}
Submitted by adam186 669 days ago
import { Resource } from 'https://deno.land/x/windmill@v1.55.0/mod.ts'
import { removeObjectEmptyFields } from 'https://deno.land/x/windmill_helpers@v1.0.0/mod.ts'
/**
* Find more information about the parameters at
* https://mailchimp.com/developer/marketing/api/campaigns/add-campaign/
*/
export async function main(
auth: Resource<'mailchimp'>,
type: 'regular' | 'plaintext' | 'rss' | 'variate',
content_type: 'template' | 'multichannel' = 'template',
rss_opts?: Record<string, any>,
recipients?: Record<string, any>,
variate_settings?: Record<string, any>,
settings?: Record<string, any>,
tracking?: Record<string, any>,
social_card?: Record<string, any>,
) {
const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns`;
const body = {
type,
content_type,
rss_opts,
recipients,
variate_settings,
settings,
tracking,
social_card
}
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${auth.api_key}`,
},
body: JSON.stringify(removeObjectEmptyFields(body)),
});
if(!response.ok) {
throw Error(await response.text())
}
return await response.json();
}
Submitted by adam186 739 days ago
/**
* @param server The data center for your Mailchimp account.
*
* Find more information about the parameters at
* https://mailchimp.com/developer/marketing/api/campaigns/add-campaign/
*/
export async function main(
api_key: string,
server: string,
type: 'regular' | 'plaintext' | 'rss' | 'variate',
content_type: 'template' | 'multichannel' = 'template',
rss_opts?: Record<string, any>,
recipients?: Record<string, any>,
variate_settings?: Record<string, any>,
settings?: Record<string, any>,
tracking?: Record<string, any>,
social_card?: Record<string, any>,
) {
const url = `https://${server}.api.mailchimp.com/3.0/campaigns`;
const body = {
type,
content_type,
rss_opts,
recipients,
variate_settings,
settings,
tracking,
social_card
}
for(const key in body) {
const field = body[<keyof typeof body>key]
if(!field || !Object.keys(field).length) {
delete body[<keyof typeof body>key]
}
}
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${api_key}`,
},
body: JSON.stringify(body),
});
if(!response.ok) {
throw Error(await response.text())
}
return await response.json();
}
Submitted by adam186 761 days ago
/**
* @param server The data center for your Mailchimp account.
*
* Find more information about the parameters at
* https://mailchimp.com/developer/marketing/api/campaigns/add-campaign/
*/
export async function main(
api_key: string,
server: string,
type: 'regular' | 'plaintext' | 'rss' | 'variate',
content_type: 'template' | 'multichannel' = 'template',
rss_opts?: Record<string, any>,
recipients?: Record<string, any>,
variate_settings?: Record<string, any>,
settings?: Record<string, any>,
tracking?: Record<string, any>,
social_card?: Record<string, any>,
) {
const url = `https://${server}.api.mailchimp.com/3.0/campaigns`;
const body = {
type,
content_type,
rss_opts,
recipients,
variate_settings,
settings,
tracking,
social_card
}
for(const key in body) {
const field = body[<keyof typeof body>key]
if(!field || !Object.keys(field).length) {
delete body[<keyof typeof body>key]
}
}
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Bearer ${api_key}`,
},
body: JSON.stringify(body),
});
return await response.json();
}
Submitted by adam186 761 days ago