Skip to content

Commit

Permalink
adding search_domain to companies
Browse files Browse the repository at this point in the history
  • Loading branch information
jpetrucciani committed Jan 22, 2019
1 parent f5ba8f8 commit 61477a4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
tmp.py
.prospector
*.pyc
.coverage
Expand Down
1 change: 1 addition & 0 deletions .prospector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ignore-patterns:
- (^|/)\..+
- .*\.html
- docs/.*
- tmp\.py

pylint:
disable:
Expand Down
38 changes: 33 additions & 5 deletions hubspot3/companies.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,45 @@ def _get_path(self, subpath):
)

def create(self, data=None, **options):
"""create a new company"""
data = data or {}
return self._call("companies/", data=data, method="POST", **options)

def update(self, key, data=None, **options):
def update(self, company_id, data=None, **options):
"""update the given company with data"""
data = data or {}
return self._call(
"companies/{}".format(key), data=data, method="PUT", **options
"companies/{}".format(company_id), data=data, method="PUT", **options
)

def get(self, companyid, **options):
return self._call("companies/{}".format(companyid), method="GET", **options)
def get(self, company_id, **options):
"""get a single company by it's ID"""
return self._call("companies/{}".format(company_id), method="GET", **options)

def search_domain(self, domain, limit=1, extra_properties=None, **options):
"""searches for companies by domain name. limit is max'd at 100"""
# default properties to fetch
properties = [
"domain",
"createdate",
"name",
"hs_lastmodifieddate",
"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)

return self._call(
"domains/{}/companies".format(domain),
method="POST",
data={"limit": limit, "requestOptions": {"properties": properties}},
**options,
)

def get_all(self, extra_properties=None, **options):
finished = False
Expand Down Expand Up @@ -72,7 +100,7 @@ def get_all(self, extra_properties=None, **options):
"offset": offset,
"properties": properties,
},
**options
**options,
)
output.extend(
[
Expand Down
2 changes: 1 addition & 1 deletion hubspot3/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""


__version__ = "3.1.8"
__version__ = "3.1.9"


BASE_URL = "https://api.hubapi.com"

0 comments on commit 61477a4

Please sign in to comment.