|
@@ -1,5 +1,7 @@
|
|
|
import json
|
|
|
import requests
|
|
|
+import config
|
|
|
+
|
|
|
#Тестовый класс User и Address (ВАЖНО!!!) поля классов должны называться также как и поля json объекта
|
|
|
|
|
|
#Full json order example
|
|
@@ -163,7 +165,7 @@ class Order(object):
|
|
|
'''
|
|
|
|
|
|
class OrderTicket(object):
|
|
|
- def __init__(self, id, status, created_date, status_changed_date, priority, title=None, note=None, due_date=None, task_list, created_by, type, assigned_to=None):
|
|
|
+ def __init__(self, id, status, created_date, status_changed_date, priority, title=None, note=None, due_date=None, task_list=None, created_by=None, type=None, assigned_to=None):
|
|
|
self.id = id
|
|
|
self.status = status
|
|
|
self.created_date = created_date
|
|
@@ -188,10 +190,10 @@ def jsonToOrder(jsonstring) -> Order:
|
|
|
return u
|
|
|
|
|
|
#Функция преобразования json в объект класса OrderTicket
|
|
|
-def jsonToTicket(jsonstring) -> OrderTicket:
|
|
|
+def jsonToOrderTicket(jsonstring) -> OrderTicket:
|
|
|
jsonObj = json.loads(jsonstring)
|
|
|
print(jsonObj)
|
|
|
- u = Order(**jsonObj)
|
|
|
+ u = OrderTicket(**jsonObj)
|
|
|
return u
|
|
|
|
|
|
#Функция обращения к апи и получение токена
|
|
@@ -227,21 +229,38 @@ def requestGetListUser():
|
|
|
print(response.json())
|
|
|
|
|
|
|
|
|
-def requestGetList(login, password, url):
|
|
|
- auth_token=requestGetToken(login, password, url)
|
|
|
+def requestGetList(auth_token, url):
|
|
|
+ #auth_token=requestGetToken(login, password, url)
|
|
|
#print(auth_token)
|
|
|
headers = {'Authorization': f'Token {auth_token}'}
|
|
|
#url = 'https://user.sharix-app.org/platform/api/sharix-users/'
|
|
|
- response = requests.get(API_URL+"/metaservicesynced/api/orders/", headers=headers)
|
|
|
+ response = requests.get(config.API_URL+"/tickets/api/tickets/?list_id=10", headers=headers)
|
|
|
+ #response = requests.get(config.API_URL+"/metaservicesynced/api/orders/", headers=headers)
|
|
|
print(response)
|
|
|
- print(response.json())
|
|
|
- if not json:
|
|
|
- print("Empty array")
|
|
|
- else:
|
|
|
- for i in json:
|
|
|
- try:
|
|
|
- order = Order(**i)
|
|
|
- print(order)
|
|
|
- except Exception as ex:
|
|
|
- print(ex)
|
|
|
+ #return response.json()
|
|
|
+ #print(response.json())
|
|
|
+ ordertext=response.json()
|
|
|
+ startlist = []
|
|
|
+
|
|
|
+ #if not ordertext:
|
|
|
+ # print("Empty array")
|
|
|
+ #else:
|
|
|
+ # for i in ordertext:
|
|
|
+ # print (i, "PROCESSING")
|
|
|
+ # try:
|
|
|
+ # orderticket = OrderTicket(**i)
|
|
|
+ # print(i, "ORDER ", orderticket)
|
|
|
+ # except Exception as ex:
|
|
|
+ # print(ex)
|
|
|
+
|
|
|
+ if ordertext is not None:
|
|
|
+ orderObj = jsonToOrderTicket(ordertext)
|
|
|
+ print (orderObj)
|
|
|
+ startlist.append(orderObj)
|
|
|
+ process_status.append(0)
|
|
|
+ bot.bot_log(str(datetime.now())+" аказ успешно добавлен в очередь обработки\n")
|
|
|
+
|
|
|
+
|
|
|
+ #print (orderticket)
|
|
|
+ return startlist
|
|
|
|