Edits history of script submission #200 for ' Get Campaign (mailchimp)'

  • deno
    One script reply has been approved by the moderators
    Ap­pro­ved
    /**
     * @param fields *(optional)* A list of fields to return in the response.
     * Reference parameters of sub-objects with dot notation.
     *
     * @param exclude_fields *(optional)* A list of fields to exclude from the response.
     * Reference parameters of sub-objects with dot notation. If both `fields` and `exclude_fields`
     * are present, then only `exclude_fields` will be used.
     */
    type Mailchimp = {
      api_key: string;
      server: string;
    };
    export async function main(
      auth: Mailchimp,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[],
    ) {
      let url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`;
      if (fields?.length) {
        url += `fields=${fields.join(",")}`;
      }
      if (exclude_fields?.length) {
        url += `${fields?.length ? "&" : ""}exclude_fields=${exclude_fields.join(
          ",",
        )}`;
      }
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: `Bearer ${auth.api_key}`,
        },
      });
    
      if (!response.ok) {
        throw Error(await response.text());
      }
      return await response.json();
    }
    

    Submitted by hugo697 378 days ago

  • deno
    /**
     * @param fields *(optional)* A list of fields to return in the response.
     * Reference parameters of sub-objects with dot notation.
     *
     * @param exclude_fields *(optional)* A list of fields to exclude from the response.
     * Reference parameters of sub-objects with dot notation. If both `fields` and `exclude_fields`
     * are present, then only `exclude_fields` will be used.
     */
    type Mailchimp = {
      api_key: string;
      server: string;
    };
    export async function main(
      auth: Mailchimp,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[],
    ) {
      let url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`;
      if (fields?.length) {
        url += `fields=${fields.join(",")}`;
      }
      if (exclude_fields?.length) {
        url += `${fields?.length ? "&" : ""}exclude_fields=${exclude_fields.join(
          ",",
        )}`;
      }
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: `Bearer ${auth.api_key}`,
        },
      });
    
      if (!response.ok) {
        throw Error(await response.text());
      }
      return await response.json();
    }
    

    Submitted by admin 1010 days ago

  • deno
    
    /**
     * @param fields *(optional)* A list of fields to return in the response.
     * Reference parameters of sub-objects with dot notation.
     * 
     * @param exclude_fields *(optional)* A list of fields to exclude from the response.
     * Reference parameters of sub-objects with dot notation. If both `fields` and `exclude_fields`
     * are present, then only `exclude_fields` will be used.
     */
    type Mailchimp = {
      api_key: string;
      server: string;
    };
    export async function main(
      auth: Mailchimp,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[]
    ) {
      let url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`
      if(fields?.length) {
        url += `fields=${fields.join(',')}`
      }
      if(exclude_fields?.length) {
        url += `${fields?.length ? '&' : ''}exclude_fields=${exclude_fields.join(',')}`
      }
    
      const response = await fetch(url, {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${auth.api_key}`
        }
      })
      
      if(!response.ok) {
        throw Error(await response.text())
      }
      return await response.json()
    }
    

    Submitted by admin 1013 days ago

  • deno
    import { Resource } from 'https://deno.land/x/[email protected]/mod.ts'
    
    /**
     * @param fields *(optional)* A list of fields to return in the response.
     * Reference parameters of sub-objects with dot notation.
     * 
     * @param exclude_fields *(optional)* A list of fields to exclude from the response.
     * Reference parameters of sub-objects with dot notation. If both `fields` and `exclude_fields`
     * are present, then only `exclude_fields` will be used.
     */
    export async function main(
      auth: Resource<'mailchimp'>,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[]
    ) {
      let url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`
      if(fields?.length) {
        url += `fields=${fields.join(',')}`
      }
      if(exclude_fields?.length) {
        url += `${fields?.length ? '&' : ''}exclude_fields=${exclude_fields.join(',')}`
      }
    
      const response = await fetch(url, {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${auth.api_key}`
        }
      })
      
      if(!response.ok) {
        throw Error(await response.text())
      }
      return await response.json()
    }
    

    Submitted by adam186 1142 days ago

  • deno
    import { Resource } from 'https://deno.land/x/[email protected]/mod.ts'
    
    /**
     * @param fields *(optional)* A list of fields to return in the response.
     * Reference parameters of sub-objects with dot notation.
     * 
     * @param exclude_fields *(optional)* A list of fields to exclude from the response.
     * Reference parameters of sub-objects with dot notation. If both `fields` and `exclude_fields`
     * are present, then only `exclude_fields` will be used.
     */
    export async function main(
      auth: Resource<'mailchimp'>,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[]
    ) {
      let url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`
      if(fields?.length) {
        url += `fields=${fields.join(',')}`
      }
      if(exclude_fields?.length) {
        url += `${fields?.length ? '&' : ''}exclude_fields=${exclude_fields.join(',')}`
      }
    
      const response = await fetch(url, {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${auth.api_key}`
        }
      })
      
      if(!response.ok) {
        throw Error(await response.text())
      }
      return await response.json()
    }
    

    Submitted by adam186 1177 days ago

  • deno
    import { Resource } from 'https://deno.land/x/[email protected]/mod.ts'
    
    /**
     * @param fields *(optional)* A list of fields to return in the response.
     * Reference parameters of sub-objects with dot notation.
     * 
     * @param exclude_fields *(optional)* A list of fields to exclude from the response.
     * Reference parameters of sub-objects with dot notation. If both `fields` and `exclude_fields`
     * are present, then only `exclude_fields` will be used.
     */
    export async function main(
      auth: Resource<'mailchimp'>,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[]
    ) {
      let url = `https://${auth.server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`
      if(fields?.length) {
        url += `fields=${fields.join(',')}`
      }
      if(exclude_fields?.length) {
        url += `${fields?.length ? '&' : ''}exclude_fields=${exclude_fields.join(',')}`
      }
    
      const response = await fetch(url, {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${auth.api_key}`
        }
      })
      
      if(!response.ok) {
        throw Error(await response.text())
      }
      return await response.json()
    }
    

    Submitted by adam186 1247 days ago

  • deno
    /**
     * @param server The data center for your Mailchimp account.
     * 
     * @param fields *(optional)* A list of fields to return in the response.
     * Reference parameters of sub-objects with dot notation.
     * 
     * @param exclude_fields *(optional)* A list of fields to exclude from the response.
     * Reference parameters of sub-objects with dot notation. If both `fields` and `exclude_fields`
     * are present, then only `exclude_fields` will be used.
     */
    export async function main(
      api_key: string,
      server: string,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[]
    ) {
      let url = `https://${server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`
      if(fields?.length) {
        url += `fields=${fields.join(',')}`
      }
      if(exclude_fields?.length) {
        url += `${fields?.length ? '&' : ''}exclude_fields=${exclude_fields.join(',')}`
      }
    
      const response = await fetch(url, {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${api_key}`
        }
      })
      
      if(!response.ok) {
        throw Error(await response.text())
      }
      return await response.json()
    }
    

    Submitted by adam186 1268 days ago

  • deno
    /**
     * @param server The data center for your Mailchimp account.
     * 
     * @param fields *(optional)* A list of fields to return in the response.
     * Reference parameters of sub-objects with dot notation.
     * 
     * @param exclude_fields *(optional)* A list of fields to exclude from the response.
     * Reference parameters of sub-objects with dot notation.
     */
    export async function main(
      api_key: string,
      server: string,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[]
    ) {
      let url = `https://${server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`
      if(fields?.length) {
        url += `fields=${fields.join(',')}`
      }
      if(exclude_fields?.length) {
        url += `${fields?.length ? '&' : ''}exclude_fields=${exclude_fields.join(',')}`
      }
    
      const response = await fetch(url, {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${api_key}`
        }
      })
      
      if(!response.ok) {
        throw Error(await response.text())
      }
      return await response.json()
    }
    

    Submitted by adam186 1268 days ago

  • deno
    /**
     * @param server The data center for your Mailchimp account.
     * 
     * @param fields *(optional)* A list of fields to return in the response.
     * Reference parameters of sub-objects with dot notation.
     * 
     * @param exclude_fields *(optional)* A list of fields to exclude from the response.
     * Reference parameters of sub-objects with dot notation.
     */
    export async function main(
      api_key: string,
      server: string,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[]
    ) {
      let url = `https://${server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`
      if(fields?.length) {
        url += `fields=${fields.join(',')}`
      }
      if(exclude_fields?.length) {
        url += `exclude_fields=${exclude_fields.join(',')}`
      }
    
      const response = await fetch(url, {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${api_key}`
        }
      })
      
      if(!response.ok) {
        throw Error(await response.text())
      }
      return await response.json()
    }
    

    Submitted by adam186 1268 days ago

  • deno
    /**
     * @param server The data center for your Mailchimp account.
     * 
     * @param fields *(optional)* A comma-separated list of fields to return.
     * Reference parameters of sub-objects with dot notation.
     * 
     * @param exclude_fields *(optional)* A comma-separated list of fields to exclude.
     * Reference parameters of sub-objects with dot notation.
     */
    export async function main(
      api_key: string,
      server: string,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[]
    ) {
      let url = `https://${server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`
      if(fields?.length) {
        url += `fields=${fields.join(',')}`
      }
      if(exclude_fields?.length) {
        url += `exclude_fields=${exclude_fields.join(',')}`
      }
    
      const response = await fetch(url, {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${api_key}`
        }
      })
      
      if(!response.ok) {
        throw Error(await response.text())
      }
      return await response.json()
    }
    

    Submitted by adam186 1268 days ago

  • deno
    /**
     * @param server The data center for your Mailchimp account.
     * 
     * @param fields *(optional)* A comma-separated list of fields to return.
     * Reference parameters of sub-objects with dot notation.
     * 
     * @param exclude_fields *(optional)* A comma-separated list of fields to exclude.
     * Reference parameters of sub-objects with dot notation.
     */
    export async function main(
      api_key: string,
      server: string,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[]
    ) {
      let url = `https://${server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`
      if(fields?.length) {
        url += `fields=${fields.join(',')}`
      }
      if(exclude_fields?.length) {
        url += `exclude_fields=${exclude_fields.join(',')}`
      }
      console.log(url)
      const response = await fetch(url, {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${api_key}`
        }
      })
      
      if(!response.ok) {
        throw Error(await response.text())
      }
      return await response.json()
    }
    

    Submitted by adam186 1268 days ago

  • deno
    /**
     * @param server The data center for your Mailchimp account.
     * 
     * @param fields *(optional)* A comma-separated list of fields to return.
     * Reference parameters of sub-objects with dot notation.
     * 
     * @param exclude_fields *(optional)* A comma-separated list of fields to exclude.
     * Reference parameters of sub-objects with dot notation.
     */
    export async function main(
      api_key: string,
      server: string,
      campaign_id: string,
      fields?: string[],
      exclude_fields?: string[]
    ) {
      let url = `https://${server}.api.mailchimp.com/3.0/campaigns/${campaign_id}?`
      if(fields?.length) {
        url += `fields=${fields.join(',')}`
      }
      if(exclude_fields?.length) {
        url += `exclude_fields=${exclude_fields.join(',')}`
      }
      console.log(url)
      const response = await fetch(url, {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${api_key}`
        }
      })
      return await response.json()
    }
    

    Submitted by adam186 1268 days ago