コード例 #1
0
    def get_all_stagehist(self, offset=0, **options):
        """get all deals in the hubspot account"""
        finished = False
        output = []
        querylimit = 250  # Max value according to docs
        while not finished:
            batch = self._call("deal/paged",
                               method="GET",
                               params={
                                   "limit":
                                   querylimit,
                                   "offset":
                                   offset,
                                   "properties": [
                                       "dealname",
                                       "dealstage",
                                       "pipeline",
                                   ],
                                   "includeAssociations":
                                   True,
                                   "includePropertyVersions":
                                   True,
                               },
                               doseq=True,
                               **options)
            output.extend([
                prettify(deal, id_key="dealId") for deal in batch["deals"]
                if not deal["isDeleted"]
            ])
            finished = not batch["hasMore"]
            offset = batch["offset"]

        return output
コード例 #2
0
    def get_all(self, **options):
        finished = False
        output = []
        offset = 0
        querylimit = 250  # Max value according to docs
        while not finished:
            batch = self._call("companies/paged",
                               method="GET",
                               doseq=True,
                               params={
                                   "limit":
                                   querylimit,
                                   "offset":
                                   offset,
                                   "properties": [
                                       "name",
                                       "description",
                                       "address",
                                       "address2",
                                       "city",
                                       "state",
                                       "story",
                                       "hubspot_owner_id",
                                   ],
                               },
                               **options)
            output.extend([
                prettify(company, id_key="companyId")
                for company in batch["companies"] if not company["isDeleted"]
            ])
            finished = not batch["has-more"]
            offset = batch["offset"]

        return output
コード例 #3
0
ファイル: companies.py プロジェクト: zimmerel/hubspot3
    def _get_recent(self, recency_type: str, **options) -> Optional[List]:
        """
        Returns either list of recently modified companies or recently created companies,
        depending on recency_type passed in. Both API endpoints take identical parameters
        and return identical formats, they differ only in the URLs
        (companies/recent/created or companies/recent/modified)
        :see: https://developers.hubspot.com/docs/methods/companies/get_companies_modified
        :see: https://developers.hubspot.com/docs/methods/companies/get_companies_created
        """
        finished = False
        output = []
        offset = 0
        query_limit = 250  # Max value according to docs

        while not finished:
            batch = self._call("companies/recent/{}".format(recency_type),
                               method="GET",
                               doseq=True,
                               params={
                                   "count": query_limit,
                                   "offset": offset
                               },
                               **options)
            output.extend([
                prettify(company, id_key="companyId")
                for company in batch["results"] if not company["isDeleted"]
            ])
            finished = not batch["hasMore"]
            offset = batch["offset"]

        return output
コード例 #4
0
    def get_all(self, limit=None, offset=0, **options):
        finished = False
        output = []
        offset = 0
        querylimit = 250  # Max value according to docs
        while not finished:
            batch = self._call('deal/paged',
                               method='GET',
                               params={
                                   'limit':
                                   querylimit,
                                   'offset':
                                   offset,
                                   'properties': [
                                       'associations', 'dealname', 'dealstage',
                                       'pipeline', 'hubspot_owner_id',
                                       'description', 'closedate', 'amount',
                                       'dealtype', 'createdate'
                                   ],
                                   'includeAssociations':
                                   True
                               },
                               doseq=True,
                               **options)
            output.extend([
                prettify(deal, id_key='dealId') for deal in batch['deals']
                if not deal['isDeleted']
            ])
            finished = not batch['hasMore']
            offset += batch['offset']

        return output
コード例 #5
0
ファイル: products.py プロジェクト: cvoege/hubspot3
    def get_all_products(self,
                         properties: List[str] = None,
                         offset: int = 0,
                         **options):
        """get all products in the hubspot account"""
        properties = properties or []
        finished = False
        output = []
        querylimit = 100  # Max value according to docs
        while not finished:
            batch = self._call("objects/products/paged",
                               method="GET",
                               params=ordered_dict({
                                   "limit":
                                   querylimit,
                                   "offset":
                                   offset,
                                   "properties":
                                   ["name", "description", *properties],
                               }),
                               doseq=True,
                               **options)
            output.extend([
                prettify(obj, id_key="objectId") for obj in batch["objects"]
                if not obj["isDeleted"]
            ])
            finished = not batch["hasMore"]
            offset = batch["offset"]

        return output
コード例 #6
0
ファイル: contacts.py プロジェクト: guysoft/hubspot3
 def get_batch(self, ids):
     batch = self._call(
         'contact/vids/batch',
         method='GET',
         doseq=True,
         params={
             'vid': ids,
             'property': [
                 'email',
                 'firstname',
                 'lastname',
                 'company',
                 'website',
                 'phone',
                 'address',
                 'city',
                 'state',
                 'zip',
                 'associatedcompanyid'
             ],
         }
     )
     # It returns a dict with IDs as keys
     return [prettify(batch[contact], id_key='vid')
             for contact in batch]
コード例 #7
0
ファイル: companies.py プロジェクト: dctikan/hubspot3
    def get_all(self, **options):
        finished = False
        output = []
        offset = 0
        querylimit = 250  # Max value according to docs
        while not finished:
            batch = self._call('companies/paged',
                               method='GET',
                               doseq=True,
                               params={
                                   'limit':
                                   querylimit,
                                   'offset':
                                   offset,
                                   'properties': [
                                       'name', 'description', 'address',
                                       'address2', 'city', 'state', 'story',
                                       'hubspot_owner_id'
                                   ],
                               },
                               **options)
            output.extend([
                prettify(company, id_key='companyId')
                for company in batch['companies'] if not company['isDeleted']
            ])
            finished = not batch['has-more']
            offset = batch['offset']

        return output
コード例 #8
0
ファイル: contacts.py プロジェクト: bejoinka/hubspot3
    def get_batch(self, ids, extra_properties: Union[list, str] = None):
        """given a batch of vids, get more of their info"""
        # default properties to fetch
        properties = [
            "email",
            "firstname",
            "lastname",
            "company",
            "website",
            "phone",
            "address",
            "city",
            "state",
            "zip",
            "associatedcompanyid",
        ]

        # append extras if they exist
        if extra_properties:
            if isinstance(extra_properties, list):
                properties += extra_properties
            if isinstance(extra_properties, str):
                properties.append(extra_properties)

        batch = self._call(
            "contact/vids/batch",
            method="GET",
            doseq=True,
            params={
                "vid": ids,
                "property": properties
            },
        )
        # It returns a dict with IDs as keys
        return [prettify(batch[contact], id_key="vid") for contact in batch]
コード例 #9
0
ファイル: contacts.py プロジェクト: thepocagency/hubspot3
 def get_batch(self, ids):
     batch = self._call(
         "contact/vids/batch",
         method="GET",
         doseq=True,
         params={
             "vid":
             ids,
             "property": [
                 "email",
                 "firstname",
                 "lastname",
                 "company",
                 "website",
                 "phone",
                 "address",
                 "city",
                 "state",
                 "zip",
                 "associatedcompanyid",
             ],
         },
     )
     # It returns a dict with IDs as keys
     return [prettify(batch[contact], id_key="vid") for contact in batch]
コード例 #10
0
ファイル: deals.py プロジェクト: zzZIMAWAKE/hubspot3
    def get_all(self,
                offset: int = 0,
                extra_properties: Union[list, str] = None,
                limit: int = -1,
                **options):
        """
        get all deals in the hubspot account.
        extra_properties: a list used to extend the properties fetched
        :see: https://developers.hubspot.com/docs/methods/deals/get-all-deals
        """
        finished = False
        output = []
        query_limit = 250  # Max value according to docs
        limited = limit > 0
        if limited and limit < query_limit:
            query_limit = limit

        # default properties to fetch
        properties = [
            "associations",
            "dealname",
            "dealstage",
            "pipeline",
            "hubspot_owner_id",
            "description",
            "closedate",
            "amount",
            "dealtype",
            "createdate",
        ]

        # append extras if they exist
        if extra_properties:
            if isinstance(extra_properties, list):
                properties += extra_properties
            if isinstance(extra_properties, str):
                properties.append(extra_properties)

        while not finished:
            batch = self._call("deal/paged",
                               method="GET",
                               params={
                                   "limit": query_limit,
                                   "offset": offset,
                                   "properties": properties,
                                   "includeAssociations": True,
                               },
                               doseq=True,
                               **options)
            output.extend([
                prettify(deal, id_key="dealId") for deal in batch["deals"]
                if not deal["isDeleted"]
            ])
            finished = not batch["hasMore"] or (limited
                                                and len(output) >= limit)
            offset = batch["offset"]

        return output if not limited else output[:limit]
コード例 #11
0
    def get_all(
        self,
        offset: int = 0,
        extra_properties: Union[list, str] = None,
        limit: int = -1,
        **options
    ):
        """
        Retrieve all the line items in the Hubspot account.

        Cf: https://developers.hubspot.com/docs/methods/line-items/get-all-line-items

        :param offset Used to get the next set of results.
        :param extra_properties By default, only the ID, the hubspot product id (`hs_product_id`)
        a few other system fields are returned for the line items. This method with also ask for
        basic properties such as the 'name', the 'price' and the 'quantity'. More could be
        retrieved by using 'extra_properties'.
        :param limit: could be used to prevent to fetch the entire results. Default value is `-1`,
        meaning unlimited.
        """
        finished = False
        output = []
        limited = limit > 0

        # Default properties to fetch
        properties = ["name", "price", "quantity"]

        # append extras if they exist
        if extra_properties:
            if isinstance(extra_properties, list):
                properties += extra_properties
            if isinstance(extra_properties, str):
                properties.append(extra_properties)

        while not finished:
            batch = self._call(
                "paged",
                method="GET",
                params=ordered_dict({"offset": offset, "properties": properties}),
                doseq=True,
                **options
            )
            output.extend(
                [
                    prettify(line_item, id_key="objectId")
                    for line_item in batch["objects"]
                    if not line_item["isDeleted"]
                ]
            )
            finished = not batch["hasMore"] or (limited and len(output) >= limit)
            offset = batch["offset"]

        return output if not limited else output[:limit]
コード例 #12
0
ファイル: deals.py プロジェクト: thepocagency/hubspot3
    def get_all(self, offset=0, extra_properties=None, **options):
        """
        get all deals in the hubspot account.
        extra_properties: a list used to extend the properties fetched
        """
        finished = False
        output = []
        querylimit = 250  # Max value according to docs

        # default properties to fetch
        properties = [
            "associations",
            "dealname",
            "dealstage",
            "pipeline",
            "hubspot_owner_id",
            "description",
            "closedate",
            "amount",
            "dealtype",
            "createdate",
        ]

        # append extras if they exist
        if extra_properties and isinstance(extra_properties, list):
            properties += extra_properties

        while not finished:
            batch = self._call(
                "deal/paged",
                method="GET",
                params={
                    "limit": querylimit,
                    "offset": offset,
                    "properties": properties,
                    "includeAssociations": True,
                },
                doseq=True,
                **options
            )
            output.extend(
                [
                    prettify(deal, id_key="dealId")
                    for deal in batch["deals"]
                    if not deal["isDeleted"]
                ]
            )
            finished = not batch["hasMore"]
            offset = batch["offset"]

        return output
コード例 #13
0
ファイル: companies.py プロジェクト: WilliamSault/hubspot3
    def get_all(
        self, extra_properties: Union[str, List] = None, **options
    ) -> Optional[List]:
        """get all companies, including extra properties if they are passed in"""
        finished = False
        output = []
        offset = 0
        query_limit = 250  # Max value according to docs

        # default properties to fetch
        properties = [
            "name",
            "description",
            "address",
            "address2",
            "city",
            "state",
            "story",
            "hubspot_owner_id",
        ]

        # append extras if they exist
        if extra_properties:
            if isinstance(extra_properties, list):
                properties += extra_properties
            if isinstance(extra_properties, str):
                properties.append(extra_properties)

        while not finished:
            batch = self._call(
                "companies/paged",
                method="GET",
                doseq=True,
                params={
                    "limit": query_limit,
                    "offset": offset,
                    "properties": properties,
                },
                **options,
            )
            output.extend(
                [
                    prettify(company, id_key="companyId")
                    for company in batch["companies"]
                    if not company["isDeleted"]
                ]
            )
            finished = not batch["has-more"]
            offset = batch["offset"]

        return output
コード例 #14
0
ファイル: deals.py プロジェクト: zimmerel/hubspot3
    def _get_recent(
        self,
        recency_type: str,
        limit: int = 100,
        offset: int = 0,
        since: int = None,
        include_versions: bool = False,
        **options
    ):
        """
        returns a list of either recently created or recently modified deals

        :param since: unix formatted timestamp in milliseconds
        """
        finished = False
        output = []
        query_limit = 100  # max according to the docs
        limited = limit > 0
        if limited and limit < query_limit:
            query_limit = limit

        while not finished:
            params = {
                "count": query_limit,
                "offset": offset,
                "includePropertyVersions": include_versions,
            }
            if since:
                params["since"] = since
            batch = self._call(
                "deal/recent/{}".format(recency_type),
                method="GET",
                params=params,
                doseq=True,
                **options
            )
            output.extend(
                [
                    prettify(deal, id_key="dealId")
                    for deal in batch["results"]
                    if not deal["isDeleted"]
                ]
            )
            finished = not batch["hasMore"] or len(output) >= limit
            offset = batch["offset"]

        return output[:limit]
コード例 #15
0
ファイル: contacts.py プロジェクト: Josephmorvan/hubspot3
 def get_batch(self, ids):
     batch = self._call(
         "contact/vids/batch",
         method="GET",
         doseq=True,
         params={
             "vid": ids,
             "property": [
                 "email",
                 "firstname",
                 "lastname",
                 "jobtitle",
                 "company",
                 "contact_city",
                 "numemployees",
                 "num_contacted_notes",
                 "hubspot_owner_id",
                 "lifecyclestage",
                 "hs_lead_status",
                 "createdate",
                 "hs_lifecyclestage_lead_date",
                 "hs_lifecyclestage_marketingqualifiedlead_date",
                 "hs_lifecyclestage_salesqualifiedlead_date",
                 "hs_lifecyclestage_opportunity_date",
                 "hs_lifecyclestage_customer_date",
                 "source",
                 "source_code",
                 "campaign_objective",
                 "campaign_name",
                 "campaign_term",
                 "hs_analytics_first_url",
                 "hs_analytics_last_url",
                 "form_name",
                 "first_conversion_event_name",
                 "recent_conversion_event_name",
                 "hs_analytics_source_data_2",
                 "associatedcompanyid",
                 "email_validity",
                 "phone",
                 "inbound_response_time",
             ],
         },
     )
     # It returns a dict with IDs as keys
     return [prettify(batch[contact], id_key="vid") for contact in batch]
コード例 #16
0
    def get_all(self, offset=0, **options):
        """get all deals in the hubspot account"""
        finished = False
        output = []
        querylimit = 250  # Max value according to docs
        while not finished:
            batch = self._call("deal/paged",
                               method="GET",
                               params={
                                   "limit":
                                   querylimit,
                                   "offset":
                                   offset,
                                   "properties": [
                                       "associations",
                                       "dealname",
                                       "dealstage",
                                       "pipeline",
                                       "hubspot_owner_id",
                                       "description",
                                       "closedate",
                                       "amount",
                                       "dealtype",
                                       "deal_source",
                                       "source_code",
                                       "city",
                                       "createdate",
                                       "number_of_employees",
                                       "number_of_terminals",
                                       "notes_last_contacted",
                                   ],
                                   "includeAssociations":
                                   True,
                               },
                               doseq=True,
                               **options)
            output.extend([
                prettify(deal, id_key="dealId") for deal in batch["deals"]
                if not deal["isDeleted"]
            ])
            finished = not batch["hasMore"]
            offset = batch["offset"]

        return output
コード例 #17
0
ファイル: contacts.py プロジェクト: sangaline/hubspot3
    def get_batch(self, ids, extra_properties: Union[list, str] = None):
        """given a batch of vids, get more of their info"""
        # default properties to fetch
        properties = self.default_batch_properties

        # append extras if they exist
        if extra_properties:
            if isinstance(extra_properties, list):
                properties += extra_properties
            if isinstance(extra_properties, str):
                properties.append(extra_properties)

        batch = self._call(
            "contact/vids/batch",
            method="GET",
            doseq=True,
            params={"vid": ids, "property": properties},
        )
        # It returns a dict with IDs as keys
        return [prettify(batch[contact], id_key="vid") for contact in batch]
コード例 #18
0
ファイル: deals.py プロジェクト: thepocagency/hubspot3
    def get_recently_modified(
        self, limit=100, offset=0, since=None, include_versions=False, **options
    ):
        """
        get recently modified deals
        up to the last 30 days or the 10k most recently modified records

        since: must be a UNIX formatted timestamp in milliseconds
        """
        finished = False
        output = []
        querylimit = 100  # max according to the docs

        while not finished:
            params = {
                "count": querylimit,
                "offset": offset,
                "includePropertyVersions": include_versions,
            }
            if since:
                params["since"] = since
            batch = self._call(
                "deal/recent/modified",
                method="GET",
                params=params,
                doseq=True,
                **options
            )
            output.extend(
                [
                    prettify(deal, id_key="dealId")
                    for deal in batch["results"]
                    if not deal["isDeleted"]
                ]
            )
            finished = not batch["hasMore"] or len(output) >= limit
            offset = batch["offset"]

        return output[:limit]
コード例 #19
0
    def get_batch(self,
                  ids,
                  extra_properties: Union[list, str] = None,
                  property_mode: str = None):
        """given a batch of vids, get more of their info"""
        # default properties to fetch
        properties = set(self.default_batch_properties)

        # append extras if they exist
        if extra_properties:
            if isinstance(extra_properties, list):
                properties.update(extra_properties)
            if isinstance(extra_properties, str):
                properties.add(extra_properties)

        if property_mode == "value_and_history":
            return self._call(
                "contact/vids/batch",
                method="GET",
                doseq=True,
                params={
                    "vid": ids,
                    "property": list(properties),
                    "propertyMode": property_mode,
                },
            )
        batch = self._call(
            "contact/vids/batch",
            method="GET",
            doseq=True,
            params={
                "vid": ids,
                "property": list(properties)
            },
        )
        # It returns a dict with IDs as keys
        return [prettify(batch[contact], id_key="vid") for contact in batch]