Edits history of script submission #202 for ' Delete Campaign (mailchimp)'

  • deno
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Mailchimp = {
      api_key: string;
      server: string;
    };
    export async function main(auth: Mailchimp, campaign_id: string) {
      const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}`;
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: `Bearer ${auth.api_key}`,
        },
      });
      if (!response.ok) {
        throw Error(await response.text());
      }
      return `Successfully deleted campaign with ID '${campaign_id}'`;
    }
    

    Submitted by hugo697 378 days ago

  • deno
    type Mailchimp = {
      api_key: string;
      server: string;
    };
    export async function main(auth: Mailchimp, campaign_id: string) {
      const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}`;
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: `Bearer ${auth.api_key}`,
        },
      });
      if (!response.ok) {
        throw Error(await response.text());
      }
      return `Successfully deleted campaign with ID '${campaign_id}'`;
    }
    

    Submitted by admin 1010 days ago

  • deno
    
    type Mailchimp = {
      api_key: string;
      server: string;
    };
    export async function main(
      auth: Mailchimp,
      campaign_id: string
    ) {
      const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}`
      const response = await fetch(url, {
        method: 'DELETE',
        headers: {
          Authorization: `Bearer ${auth.api_key}`
        }
      })
      if(!response.ok) {
        throw Error(await response.text())
      }
      return `Successfully deleted campaign with ID '${campaign_id}'`
    }
    

    Submitted by admin 1013 days ago

  • deno
    import { Resource } from 'https://deno.land/x/[email protected]/mod.ts'
    
    export async function main(
      auth: Resource<'mailchimp'>,
      campaign_id: string
    ) {
      const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}`
      const response = await fetch(url, {
        method: 'DELETE',
        headers: {
          Authorization: `Bearer ${auth.api_key}`
        }
      })
      if(!response.ok) {
        throw Error(await response.text())
      }
      return `Successfully deleted campaign with ID '${campaign_id}'`
    }
    

    Submitted by adam186 1142 days ago

  • deno
    import { Resource } from 'https://deno.land/x/[email protected]/mod.ts'
    
    export async function main(
      auth: Resource<'mailchimp'>,
      campaign_id: string
    ) {
      const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}`
      const response = await fetch(url, {
        method: 'DELETE',
        headers: {
          Authorization: `Bearer ${auth.api_key}`
        }
      })
      if(!response.ok) {
        throw Error(await response.text())
      }
      return `Successfully deleted campaign with ID '${campaign_id}'`
    }
    

    Submitted by adam186 1177 days ago

  • deno
    import { Resource } from 'https://deno.land/x/[email protected]/mod.ts'
    
    export async function main(
      auth: Resource<'mailchimp'>,
      campaign_id: string
    ) {
      const url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}`
      const response = await fetch(url, {
        method: 'DELETE',
        headers: {
          Authorization: `Bearer ${auth.api_key}`
        }
      })
      if(!response.ok) {
        throw Error(await response.text())
      }
      return `Successfully deleted campaign with ID '${campaign_id}'`
    }
    

    Submitted by adam186 1247 days ago

  • deno
    /**
     * @param server The data center for your Mailchimp account.
     */
    export async function main(
      api_key: string,
      server: string,
      campaign_id: string
    ) {
      const url = `https://${server}.api.mailchimp.com/3.0/campaigns/${campaign_id}`
      const response = await fetch(url, {
        method: 'DELETE',
        headers: {
          Authorization: `Bearer ${api_key}`
        }
      })
      if(!response.ok) {
        throw Error(await response.text())
      }
      return `Successfully deleted campaign with ID '${campaign_id}'`
    }
    

    Submitted by adam186 1268 days ago

  • deno
    /**
     * @param server The data center for your Mailchimp account.
     */
    export async function main(
      api_key: string,
      server: string,
      campaign_id: string
    ) {
      const url = `https://${server}.api.mailchimp.com/3.0/campaigns/${campaign_id}`
      try {
        const response = await fetch(url, {
          method: 'DELETE',
          headers: {
            Authorization: `Bearer ${api_key}`
          }
        })
        if(!response.ok) {
          throw Error(await response.text())
        }
        return `Successfully deleted campaign with ID '${campaign_id}'`
      } catch(err) {
        throw Error(err)
      }
    }
    

    Submitted by adam186 1268 days ago