Edits history of script submission #230 for ' Get Deal (hubspot)'

  • deno
    One script reply has been approved by the moderators
    Ap­pro­ved
    import { Client } from "npm:@hubspot/api-client@^8.1.0";
    
    /**
     * @param deal_id You may find it in the HubSpot App under the name of `Record ID`
     *
     * @param properties List of the properties to be returned in the response.
     *
     * @param properties_with_history List of the properties to be returned
     * along with their history of previous values.
     *
     * @param id_property The name of a property whose values are unique for this object type.
     */
    type Hubspot = {
      token: string;
    };
    export async function main(
      auth: Hubspot,
      deal_id: string,
      properties?: string[],
      properties_with_history?: string[],
      associations?: string[],
      archived?: boolean,
      id_property?: string,
    ) {
      const client = new Client({
        accessToken: auth.token,
      });
    
      try {
        return await client.crm.deals.basicApi.getById(
          deal_id,
          getProp(properties),
          getProp(properties_with_history),
          getProp(associations),
          archived || undefined,
          id_property || undefined,
        );
      } catch (e) {
        throw Error(`
          ${e.code}\n
          Message: ${e.body.message || e.body}\n
        `);
      }
    }
    
    function getProp(prop?: string[]) {
      return Array.isArray(prop) && prop.length ? prop : undefined;
    }
    

    Submitted by hugo697 392 days ago

  • deno
    import { Client } from "npm:@hubspot/api-client@^8.1.0";
    
    /**
     * @param deal_id You may find it in the HubSpot App under the name of `Record ID`
     *
     * @param properties List of the properties to be returned in the response.
     *
     * @param properties_with_history List of the properties to be returned
     * along with their history of previous values.
     *
     * @param id_property The name of a property whose values are unique for this object type.
     */
    type Hubspot = {
      token: string;
    };
    export async function main(
      auth: Hubspot,
      deal_id: string,
      properties?: string[],
      properties_with_history?: string[],
      associations?: string[],
      archived?: boolean,
      id_property?: string,
    ) {
      const client = new Client({
        accessToken: auth.token,
      });
    
      try {
        return await client.crm.deals.basicApi.getById(
          deal_id,
          getProp(properties),
          getProp(properties_with_history),
          getProp(associations),
          archived || undefined,
          id_property || undefined,
        );
      } catch (e) {
        throw Error(`
          ${e.code}\n
          Message: ${e.body.message || e.body}\n
        `);
      }
    }
    
    function getProp(prop?: string[]) {
      return Array.isArray(prop) && prop.length ? prop : undefined;
    }
    

    Submitted by admin 1024 days ago

  • deno
    import { Client } from "npm:@hubspot/api-client@^8.1.0"
    
    /**
     * @param deal_id You may find it in the HubSpot App under the name of `Record ID`
     * 
     * @param properties List of the properties to be returned in the response.
     * 
     * @param properties_with_history List of the properties to be returned 
     * along with their history of previous values.
     * 
     * @param id_property The name of a property whose values are unique for this object type.
     */
    type Hubspot = {
      token: string;
    };
    export async function main(
      auth: Hubspot,
      deal_id: string,
      properties?: string[],
      properties_with_history?: string[],
      associations?: string[],
      archived?: boolean,
      id_property?: string
    ) {
      const client = new Client({
        accessToken: auth.token
      })
    
      try {
        return await client.crm.deals.basicApi.getById(
          deal_id,
          getProp(properties),
          getProp(properties_with_history),
          getProp(associations),
          archived || undefined,
          id_property || undefined
        );
      } catch (e) {
        throw Error(`
          ${e.code}\n
          Message: ${e.body.message || e.body}\n
        `)
      }
    }
    
    function getProp(prop?: string[]) {
      return (Array.isArray(prop) && prop.length) ? prop : undefined
    }
    

    Submitted by admin 1028 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts"
    import { Client } from "npm:@hubspot/api-client@^8.1.0"
    
    /**
     * @param deal_id You may find it in the HubSpot App under the name of `Record ID`
     * 
     * @param properties List of the properties to be returned in the response.
     * 
     * @param properties_with_history List of the properties to be returned 
     * along with their history of previous values.
     * 
     * @param id_property The name of a property whose values are unique for this object type.
     */
    export async function main(
      auth: wmill.Resource<"hubspot">,
      deal_id: string,
      properties?: string[],
      properties_with_history?: string[],
      associations?: string[],
      archived?: boolean,
      id_property?: string
    ) {
      const client = new Client({
        accessToken: auth.token
      })
    
      try {
        return await client.crm.deals.basicApi.getById(
          deal_id,
          getProp(properties),
          getProp(properties_with_history),
          getProp(associations),
          archived || undefined,
          id_property || undefined
        );
      } catch (e) {
        throw Error(`
          ${e.code}\n
          Message: ${e.body.message || e.body}\n
        `)
      }
    }
    
    function getProp(prop?: string[]) {
      return (Array.isArray(prop) && prop.length) ? prop : undefined
    }
    

    Submitted by adam186 1156 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts"
    import { Client } from "npm:@hubspot/api-client@^8.1.0"
    
    /**
     * @param deal_id You may find it in the HubSpot App under the name of `Record ID`
     * 
     * @param properties List of the properties to be returned in the response.
     * 
     * @param properties_with_history List of the properties to be returned 
     * along with their history of previous values.
     * 
     * @param id_property The name of a property whose values are unique for this object type.
     */
    export async function main(
      auth: wmill.Resource<"hubspot">,
      deal_id: string,
      properties?: string[],
      properties_with_history?: string[],
      associations?: string[],
      archived?: boolean,
      id_property?: string
    ) {
      const client = new Client({
        accessToken: auth.token
      })
    
      try {
        return await client.crm.deals.basicApi.getById(
          deal_id,
          getProp(properties),
          getProp(properties_with_history),
          getProp(associations),
          archived || undefined,
          id_property || undefined
        );
      } catch (e) {
        throw Error(`
          ${e.code}\n
          Message: ${e.body.message || e.body}\n
        `)
      }
    }
    
    function getProp(prop?: string[]) {
      return (Array.isArray(prop) && prop.length) ? prop : undefined
    }
    

    Submitted by adam186 1191 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts"
    import { Client } from "npm:@hubspot/api-client@^8.1.0"
    
    /**
     * @param deal_id You may find it in the HubSpot App under the name of `Record ID`
     * 
     * @param properties List of the properties to be returned in the response.
     * 
     * @param properties_with_history List of the properties to be returned 
     * along with their history of previous values.
     * 
     * @param id_property The name of a property whose values are unique for this object type.
     */
    export async function main(
      auth: wmill.Resource<"hubspot">,
      deal_id: string,
      properties?: string[],
      properties_with_history?: string[],
      associations?: string[],
      archived?: boolean,
      id_property?: string
    ) {
      const client = new Client({
        accessToken: auth.token
      })
    
      try {
        return await client.crm.deals.basicApi.getById(
          deal_id,
          getProp(properties),
          getProp(properties_with_history),
          getProp(associations),
          archived || undefined,
          id_property || undefined
        );
      } catch (e) {
        throw Error(`
          ${e.code}\n
          Message: ${e.body.message || e.body}\n
        `)
      }
    }
    
    function getProp(prop?: string[]) {
      return (Array.isArray(prop) && prop.length) ? prop : undefined
    }
    

    Submitted by adam186 1274 days ago