Skip to content

Commit

Permalink
Merge pull request #68 from BureauxLocaux/feature/add-lines-update
Browse files Browse the repository at this point in the history
Add LinesClient update method
  • Loading branch information
jpetrucciani committed Oct 15, 2019
2 parents d260d47 + 1dc2628 commit 9275579
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hubspot3/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def get(self, line_id: int, **options) -> Dict:
"""
return self._call("{}".format(line_id), **options)

def update(self, line_id: int, data=None, **options) -> Dict:
"""
Update an existing line by its ID.
:see: https://developers.hubspot.com/docs/methods/line-items/update-line-item
"""
return self._call("{}".format(line_id), data=data, method="PUT", **options)

def get_all(
self,
offset: int = 0,
Expand Down
16 changes: 16 additions & 0 deletions hubspot3/test/test_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ def test_get(self, lines_client, mock_connection):
)
assert resp == response_body

def test_update(self, lines_client, mock_connection):
line_item_id = "1234"
data = {
"properties": [{"name": "name", "value": "Custom name for the line item"}]
}
response_body = {"objectType": "LINE_ITEM", "objectId": "1234"}
mock_connection.set_response(200, json.dumps(response_body))
response = lines_client.update(line_item_id, data)
mock_connection.assert_num_requests(1)
mock_connection.assert_has_request(
method="PUT",
url="/crm-objects/v1/objects/line_items/{}?".format(line_item_id),
data=data,
)
assert response == response_body

def test_get_all(self, lines_client, mock_connection):
response_body = {
"objects": [
Expand Down

0 comments on commit 9275579

Please sign in to comment.