Edits history of script submission #207 for ' Search Lists (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.
     *
     * @param before_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param before_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     */
    type Mailchimp = {
      api_key: string;
      server: string;
    };
    export async function main(
      auth: Mailchimp,
      fields?: string[],
      exclude_fields?: string[],
      count?: number,
      offset?: number,
      sort_dir?: "" | "ASC" | "DESC",
      before_date_created?: string,
      since_date_created?: string,
      before_campaign_last_sent?: string,
      since_campaign_last_sent?: string,
      email?: string,
      sort_field?: "" | "date_created",
      has_ecommerce_store?: boolean,
      include_total_contacts?: boolean,
    ) {
      const url = new URL(`https://${auth.server}.api.mailchimp.com/3.0/lists`);
      const params = {
        fields,
        exclude_fields,
        count,
        offset,
        sort_dir,
        before_date_created,
        since_date_created,
        before_campaign_last_sent,
        since_campaign_last_sent,
        email,
        sort_field,
        has_ecommerce_store,
        include_total_contacts,
      };
      for (const key in params) {
        const value = params[<keyof typeof params>key];
        if (value) {
          url.searchParams.append(
            key,
            Array.isArray(value) ? value.join(",") : "" + value,
          );
        }
      }
    
      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.
     *
     * @param before_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param before_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     */
    type Mailchimp = {
      api_key: string;
      server: string;
    };
    export async function main(
      auth: Mailchimp,
      fields?: string[],
      exclude_fields?: string[],
      count?: number,
      offset?: number,
      sort_dir?: "" | "ASC" | "DESC",
      before_date_created?: string,
      since_date_created?: string,
      before_campaign_last_sent?: string,
      since_campaign_last_sent?: string,
      email?: string,
      sort_field?: "" | "date_created",
      has_ecommerce_store?: boolean,
      include_total_contacts?: boolean,
    ) {
      const url = new URL(`https://${auth.server}.api.mailchimp.com/3.0/lists`);
      const params = {
        fields,
        exclude_fields,
        count,
        offset,
        sort_dir,
        before_date_created,
        since_date_created,
        before_campaign_last_sent,
        since_campaign_last_sent,
        email,
        sort_field,
        has_ecommerce_store,
        include_total_contacts,
      };
      for (const key in params) {
        const value = params[<keyof typeof params>key];
        if (value) {
          url.searchParams.append(
            key,
            Array.isArray(value) ? value.join(",") : "" + value,
          );
        }
      }
    
      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.
     * 
     * @param before_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param before_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     */
    type Mailchimp = {
      api_key: string;
      server: string;
    };
    export async function main(
      auth: Mailchimp,
      fields?: string[],
      exclude_fields?: string[],
      count?: number,
      offset?: number,
      sort_dir?: '' | 'ASC' | 'DESC',
      before_date_created?: string,
      since_date_created?: string,
      before_campaign_last_sent?: string,
      since_campaign_last_sent?: string,
      email?: string,
      sort_field?: '' | 'date_created',
      has_ecommerce_store?: boolean,
      include_total_contacts?: boolean,
    ) {
      const url = new URL(`https://${auth.server}.api.mailchimp.com/3.0/lists`)
      const params = {
        fields,
        exclude_fields,
        count,
        offset,
        sort_dir,
        before_date_created,
        since_date_created,
        before_campaign_last_sent,
        since_campaign_last_sent,
        email,
        sort_field,
        has_ecommerce_store,
        include_total_contacts
      }
      for(const key in params) {
        const value = params[<keyof typeof params>key]
        if(value) {
          url.searchParams.append(key, Array.isArray(value) ? value.join(',') : '' + value)
        }
      }
    
      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.
     * 
     * @param before_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param before_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     */
    export async function main(
      auth: Resource<'mailchimp'>,
      fields?: string[],
      exclude_fields?: string[],
      count?: number,
      offset?: number,
      sort_dir?: '' | 'ASC' | 'DESC',
      before_date_created?: string,
      since_date_created?: string,
      before_campaign_last_sent?: string,
      since_campaign_last_sent?: string,
      email?: string,
      sort_field?: '' | 'date_created',
      has_ecommerce_store?: boolean,
      include_total_contacts?: boolean,
    ) {
      const url = new URL(`https://${auth.server}.api.mailchimp.com/3.0/lists`)
      const params = {
        fields,
        exclude_fields,
        count,
        offset,
        sort_dir,
        before_date_created,
        since_date_created,
        before_campaign_last_sent,
        since_campaign_last_sent,
        email,
        sort_field,
        has_ecommerce_store,
        include_total_contacts
      }
      for(const key in params) {
        const value = params[<keyof typeof params>key]
        if(value) {
          url.searchParams.append(key, Array.isArray(value) ? value.join(',') : '' + value)
        }
      }
    
      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.
     * 
     * @param before_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param before_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     */
    export async function main(
      auth: Resource<'mailchimp'>,
      fields?: string[],
      exclude_fields?: string[],
      count?: number,
      offset?: number,
      sort_dir?: '' | 'ASC' | 'DESC',
      before_date_created?: string,
      since_date_created?: string,
      before_campaign_last_sent?: string,
      since_campaign_last_sent?: string,
      email?: string,
      sort_field?: '' | 'date_created',
      has_ecommerce_store?: boolean,
      include_total_contacts?: boolean,
    ) {
      const url = new URL(`https://${auth.server}.api.mailchimp.com/3.0/lists`)
      const params = {
        fields,
        exclude_fields,
        count,
        offset,
        sort_dir,
        before_date_created,
        since_date_created,
        before_campaign_last_sent,
        since_campaign_last_sent,
        email,
        sort_field,
        has_ecommerce_store,
        include_total_contacts
      }
      for(const key in params) {
        const value = params[<keyof typeof params>key]
        if(value) {
          url.searchParams.append(key, Array.isArray(value) ? value.join(',') : '' + value)
        }
      }
    
      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.
     * 
     * @param before_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param before_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     */
    export async function main(
      auth: Resource<'mailchimp'>,
      fields?: string[],
      exclude_fields?: string[],
      count?: number,
      offset?: number,
      sort_dir?: '' | 'ASC' | 'DESC',
      before_date_created?: string,
      since_date_created?: string,
      before_campaign_last_sent?: string,
      since_campaign_last_sent?: string,
      email?: string,
      sort_field?: '' | 'date_created',
      has_ecommerce_store?: boolean,
      include_total_contacts?: boolean,
    ) {
      const url = new URL(`https://${auth.server}.api.mailchimp.com/3.0/lists`)
      const params = {
        fields,
        exclude_fields,
        count,
        offset,
        sort_dir,
        before_date_created,
        since_date_created,
        before_campaign_last_sent,
        since_campaign_last_sent,
        email,
        sort_field,
        has_ecommerce_store,
        include_total_contacts
      }
      for(const key in params) {
        const value = params[<keyof typeof params>key]
        if(value) {
          url.searchParams.append(key, Array.isArray(value) ? value.join(',') : '' + value)
        }
      }
    
      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 1248 days ago

  • deno
    import { Resource } from 'https://deno.land/x/[email protected]/mod.ts'
    
    /**
     * @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.
     * 
     * @param before_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_date_created *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param before_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_campaign_last_sent *(optional)* Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     */
    export async function main(
      auth: Resource<'mailchimp'>,
      fields?: string[],
      exclude_fields?: string[],
      count?: number,
      offset?: number,
      sort_dir?: '' | 'ASC' | 'DESC',
      before_date_created?: string,
      since_date_created?: string,
      before_campaign_last_sent?: string,
      since_campaign_last_sent?: string,
      email?: string,
      sort_field?: '' | 'date_created',
      has_ecommerce_store?: boolean,
      include_total_contacts?: boolean,
    ) {
      const url = new URL(`https://${auth.server}.api.mailchimp.com/3.0/lists`)
      const params = {
        fields,
        exclude_fields,
        count,
        offset,
        sort_dir,
        before_date_created,
        since_date_created,
        before_campaign_last_sent,
        since_campaign_last_sent,
        email,
        sort_field,
        has_ecommerce_store,
        include_total_contacts
      }
      for(const key in params) {
        const value = params[<keyof typeof params>key]
        if(value) {
          url.searchParams.append(key, Array.isArray(value) ? value.join(',') : '' + value)
        }
      }
    
      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 1248 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.
     * 
     * @param before_date_created Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_date_created Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param before_campaign_last_sent Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     * @param since_campaign_last_sent Uses ISO 8601 time format: `2022-10-21T15:41:36+00:00`.
     */
    export async function main(
      api_key: string,
      server: string,
      fields?: string[],
      exclude_fields?: string[],
      count?: number,
      offset?: number,
      sort_dir?: '' | 'ASC' | 'DESC',
      before_date_created?: string,
      since_date_created?: string,
      before_campaign_last_sent?: string,
      since_campaign_last_sent?: string,
      email?: string,
      sort_field?: '' | 'date_created',
      has_ecommerce_store?: boolean,
      include_total_contacts?: boolean,
    ) {
      const url = new URL(`https://${server}.api.mailchimp.com/3.0/lists`)
      const params = {
        fields,
        exclude_fields,
        count,
        offset,
        sort_dir,
        before_date_created,
        since_date_created,
        before_campaign_last_sent,
        since_campaign_last_sent,
        email,
        sort_field,
        has_ecommerce_store,
        include_total_contacts
      }
      for(const key in params) {
        const value = params[<keyof typeof params>key]
        if(value) {
          url.searchParams.append(key, Array.isArray(value) ? value.join(',') : '' + value)
        }
      }
    
      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