add the ticket agent's patch method
parent
8db72dd9b2
commit
8c59879478
|
@ -813,6 +813,19 @@ class TicketAgentItem:
|
|||
def on_patch(req, resp, id_):
|
||||
if not id_.isdigit() or int(id_) <= 0:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, '400 Bad Request')
|
||||
try:
|
||||
raw_json = req.stream.read().decode('utf-8')
|
||||
except Exception as ex:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.ERROR', description=ex)
|
||||
|
||||
new_values = json.loads(raw_json)
|
||||
|
||||
for _name in new_values.keys():
|
||||
if len(str(new_values[_name])) == 0:
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_FIELD' + _name)
|
||||
|
||||
payload = new_values
|
||||
|
||||
ticket_id = int(id_)
|
||||
session = login()
|
||||
|
@ -820,11 +833,12 @@ class TicketAgentItem:
|
|||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
get_resp = session.patch(url, headers=headers)
|
||||
get_resp = session.patch(url, headers=headers, data=json.dumps(payload))
|
||||
content = json.loads(get_resp.text)
|
||||
print("TicketAgentItem content", content)
|
||||
resp.text = json.dumps(content)
|
||||
|
||||
|
||||
class ContactItem:
|
||||
@staticmethod
|
||||
def __init__():
|
||||
|
|
Loading…
Reference in New Issue