diff --git a/hubspot3/lines.py b/hubspot3/lines.py index 45fd847..089750a 100644 --- a/hubspot3/lines.py +++ b/hubspot3/lines.py @@ -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, diff --git a/hubspot3/test/test_lines.py b/hubspot3/test/test_lines.py index ec9c6cb..a606a5f 100644 --- a/hubspot3/test/test_lines.py +++ b/hubspot3/test/test_lines.py @@ -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": [