Skip to content

Commit 5b84252

Browse files
committed
Add update line item
1 parent 87ea217 commit 5b84252

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

dynatademand/api.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
SCHEMAS = [
99
"project_new",
10+
"lineitem_update",
1011
]
1112

1213

@@ -170,6 +171,22 @@ def get_project_detailed_report(self, project_id):
170171
def get_line_item(self, project_id, line_item_id):
171172
return self._api_get('/projects/{}/lineItems/{}'.format(project_id, line_item_id))
172173

174+
def update_line_item(self, project_id, lineitem_id, lineitem_data):
175+
'''
176+
Updates the specified line item by setting the values of the parameters passed.
177+
Any parameters not provided will be left unchanged.
178+
'''
179+
# Update an existing line item. Uses the "lineitem_update" schema.
180+
self._validate_object("lineitem_update", lineitem_data)
181+
response_data = self._api_post('/projects/{}/lineItems/{}'.format(project_id, lineitem_id), lineitem_data)
182+
if response_data.get('status').get('message') != 'success':
183+
raise DemandAPIError(
184+
"Could not update line item. Demand API responded with: {}".format(
185+
response_data
186+
)
187+
)
188+
return response_data
189+
173190
def get_line_items(self, project_id):
174191
return self._api_get('/projects/{}/lineItems'.format(project_id))
175192

0 commit comments

Comments
 (0)