Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement named property fetching #96

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions hubspot3/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ def get_all(self, object_type):
"", method="GET", params={"properties": ["name", "label", "description"]}
)

def get(self, object_type: str, code: str):
"""Retrieve a property."""

# Save the current object type.
self._object_type = object_type

return self._call("named/{}".format(code), method="GET")

def delete(self, object_type, code):
"""Delete a custom property."""

Expand Down
24 changes: 23 additions & 1 deletion hubspot3/test/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def properties_input_data():
)


class TestContactsClient(object):
class TestPropertiesClient(object):
@pytest.mark.parametrize(
"object_type, api_version",
[
Expand Down Expand Up @@ -153,3 +153,25 @@ def test_update(
data,
)
assert resp == response_body

def test_get(self, properties_client, mock_connection, properties_input_data):
input_data = properties_input_data
response_body = {
"name": input_data["code"],
"label": input_data["label"],
"description": input_data["description"],
"groupName": "custom",
"type": "string",
"fieldType": "text",
"formField": True,
"displayOrder": 3,
"options": [],
}
mock_connection.set_response(200, json.dumps(response_body))
resp = properties_client.get(OBJECT_TYPE_DEALS, input_data["code"])
mock_connection.assert_num_requests(1)
mock_connection.assert_has_request(
"GET",
"/properties/v1/deals/properties/named/{}?".format(input_data["code"]),
)
assert resp == response_body