|
@@ -60,16 +60,70 @@ https://wiki.sharix-app.org/doku.php/open/tech/dev/sharix_open_-_primery_json
|
|
|
}
|
|
|
'''
|
|
|
#надо адаптировать класс к новому формату JSON
|
|
|
-class Order(object):
|
|
|
- def __init__(self, order_synced, ticket, status, title, note, due_date, id_metaservice, is_global, is_visible, service, service_type, status_changed_date, time_placed, time_start=None, time_start_predicted=None, time_finish_predicted=None, time_start_real=None, time_finish_real=None, order_place_type=None, order_place_start=None, order_place_start_gps=None, order_place_start_real=None, order_place_start_real_gps=None, order_place_finish_predicted=None, order_place_finish_predicted_gps=None, order_place_finish_real=None, order_place_finish_real_gps=None, predicted_price=None, real_price=None, payment_transaction_id=None, rating_id=None, provider=None, provider_screen_name=None, receiver=None, receiver_screen_name=None, client_id=None, resource_id=None, attempts=None, asap=None):
|
|
|
- self.order_synced = order_synced
|
|
|
+# class Order(object):
|
|
|
+# def __init__(self, id,order_synced, ticket, status, title, note, due_date, id_metaservice, is_global, is_visible, service, service_type, status_changed_date,time_created, time_placed, time_start=None, time_start_predicted=None, time_finish_predicted=None, time_start_real=None, time_finish_real=None, order_place_type=None, order_place_start=None, order_place_start_gps=None, order_place_start_real=None, order_place_start_real_gps=None, order_place_finish_predicted=None, order_place_finish_predicted_gps=None, order_place_finish_real=None, order_place_finish_real_gps=None, predicted_price=None, real_price=None, payment_transaction_id=None, rating_id=None, provider=None, provider_screen_name=None, receiver=None, receiver_screen_name=None, client_id=None, resource_id=None, attempts=None, asap=None):
|
|
|
+# self.order_synced = order_synced
|
|
|
+# self.id = id
|
|
|
+# self.ticket = ticket
|
|
|
+# self.status = status
|
|
|
+
|
|
|
+# self.title = title
|
|
|
+# self.note = note
|
|
|
+# self.due_date = due_date
|
|
|
+
|
|
|
+# self.id_metaservice = id_metaservice
|
|
|
+# self.is_global = is_global
|
|
|
+# self.is_visible = is_visible
|
|
|
+# self.service = service
|
|
|
+# self.service_type = service_type
|
|
|
|
|
|
+# self.status_changed_date = status_changed_date
|
|
|
+# self.time_created = time_created
|
|
|
+# self.time_placed = time_placed
|
|
|
+# self.time_start = time_start
|
|
|
+# self.time_start_predicted = time_start_predicted
|
|
|
+# self.time_finish_predicted = time_finish_predicted
|
|
|
+# self.time_start_real = time_start_real
|
|
|
+# self.time_finish_real = time_finish_real
|
|
|
+
|
|
|
+# self.order_place_type =order_place_type
|
|
|
+# self.order_place_start = order_place_start
|
|
|
+# self.order_place_start_gps = order_place_start_gps
|
|
|
+# self.order_place_start_real = order_place_start_real
|
|
|
+# self.order_place_start_real_gps = order_place_start_real_gps
|
|
|
+# self.order_place_finish_predicted = order_place_finish_predicted
|
|
|
+# self.order_place_finish_predicted_gps = order_place_finish_predicted_gps
|
|
|
+# self.order_place_finish_real = order_place_finish_real
|
|
|
+# self.order_place_finish_real_gps = order_place_finish_real_gps
|
|
|
+
|
|
|
+# self.predicted_price = predicted_price
|
|
|
+# self.real_price = real_price
|
|
|
+
|
|
|
+# self.payment_transaction_id = payment_transaction_id
|
|
|
+# self.rating_id = rating_id
|
|
|
+
|
|
|
+# self.provider = provider
|
|
|
+# self.provider_screen_name = provider_screen_name
|
|
|
+# self.receiver = receiver
|
|
|
+# self.receiver_screen_name = receiver_screen_name
|
|
|
+# self.client_id = client_id
|
|
|
+# self.resource_id = resource_id
|
|
|
+# self.attempts = attempts
|
|
|
+# self.asap = asap
|
|
|
+# #доделать до конца по аналогии с закоммиченным json
|
|
|
+# def __str__(self):
|
|
|
+# return "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, {23}, {24}, {25}, {26}, {27}, {28}, {29}, {30}, {31}, {32} , {33} ,{34}".format(self.order_synced, self.id, self.ticket, self.status, self.title, self.note, self.due_date, self.id_metaservice, self.is_global, self.is_visible, self.service, self.service_type, self.status_changed_date, self.time_created,self.time_placed, self.time_start, self.time_start_predicted, self.time_finish_predicted, self.time_start_real, self.time_finish_real, self.order_place_type, self.order_place_start, self.order_place_start_gps, self.order_place_start_real, self.order_place_start_real_gps, self.order_place_finish_predicted, self.order_place_finish_predicted_gps, self.order_place_finish_real, self.order_place_finish_real_gps, self.predicted_price, self.real_price, self.payment_transaction_id, self.rating_id, self.provider, self.provider_screen_name, self.receiver, self.receiver_screen_name, self.client_id, self.resource_id, self.attempts, self.asap)
|
|
|
+
|
|
|
+ #\n добавляете в местах с пустой строкой в шаблоне
|
|
|
+
|
|
|
+class Order(object):
|
|
|
+ def __init__(self, id, ticket, status, title, note, id_metaservice, is_global, is_visible, service, service_type,time_created, time_placed, time_start=None, time_start_predicted=None, time_finish_predicted=None, time_start_real=None, time_finish_real=None, order_place_type=None, order_place_start=None, order_place_start_gps=None, order_place_start_real=None, order_place_start_real_gps=None, order_place_finish_predicted=None, order_place_finish_predicted_gps=None, order_place_finish_real=None, order_place_finish_real_gps=None, predicted_price=None, real_price=None, payment_transaction_id=None, rating_id=None, provider=None, provider_screen_name=None, receiver=None, receiver_screen_name=None, client_id=None, resource_id=None, attempts=None, asap=None):
|
|
|
+ self.id = id
|
|
|
self.ticket = ticket
|
|
|
self.status = status
|
|
|
|
|
|
self.title = title
|
|
|
self.note = note
|
|
|
- self.due_date = due_date
|
|
|
|
|
|
self.id_metaservice = id_metaservice
|
|
|
self.is_global = is_global
|
|
@@ -77,7 +131,7 @@ class Order(object):
|
|
|
self.service = service
|
|
|
self.service_type = service_type
|
|
|
|
|
|
- self.status_changed_date = status_changed_date
|
|
|
+ self.time_created = time_created
|
|
|
self.time_placed = time_placed
|
|
|
self.time_start = time_start
|
|
|
self.time_start_predicted = time_start_predicted
|
|
@@ -111,10 +165,11 @@ class Order(object):
|
|
|
self.asap = asap
|
|
|
#доделать до конца по аналогии с закоммиченным json
|
|
|
def __str__(self):
|
|
|
- return "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, {23}, {24}, {25}, {26}, {27}, {28}, {29}, {30}, {31}, {32}".format(self.order_synced, self.ticket, self.status, self.title, self.note, self.due_date, self.id_metaservice, self.is_global, self.is_visible, self.service, self.service_type, self.status_changed_date, self.time_placed, self.time_start, self.time_start_predicted, self.time_finish_predicted, self.time_start_real, self.time_finish_real, self.order_place_type, self.order_place_start, self.order_place_start_gps, self.order_place_start_real, self.order_place_start_real_gps, self.order_place_finish_predicted, self.order_place_finish_predicted_gps, self.order_place_finish_real, self.order_place_finish_real_gps, self.predicted_price, self.real_price, self.payment_transaction_id, self.rating_id, self.provider, self.provider_screen_name, self.receiver, self.receiver_screen_name, self.client_id, self.resource_id, self.attempts, self.asap)
|
|
|
+ return "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, {23}, {24}, {25}, {26}, {27}, {28}, {29}, {30}, {31}".format( self.id, self.ticket, self.status, self.title, self.note, self.id_metaservice, self.is_global, self.is_visible, self.service, self.service_type, self.time_created,self.time_placed, self.time_start, self.time_start_predicted, self.time_finish_predicted, self.time_start_real, self.time_finish_real, self.order_place_type, self.order_place_start, self.order_place_start_gps, self.order_place_start_real, self.order_place_start_real_gps, self.order_place_finish_predicted, self.order_place_finish_predicted_gps, self.order_place_finish_real, self.order_place_finish_real_gps, self.predicted_price, self.real_price, self.payment_transaction_id, self.rating_id, self.provider, self.provider_screen_name, self.receiver, self.receiver_screen_name, self.client_id, self.resource_id, self.attempts, self.asap)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- #\n добавляете в местах с пустой строкой в шаблоне
|
|
|
-
|
|
|
|
|
|
#ticket json example
|
|
|
'''
|
|
@@ -217,10 +272,12 @@ def jsonToOrderTicket(jsonstring) -> OrderTicket:
|
|
|
u = OrderTicket(**jsonObj)
|
|
|
return u
|
|
|
|
|
|
+
|
|
|
+
|
|
|
#Функция обращения к апи и получение токена
|
|
|
def requestGetToken(login, password, url) -> str:
|
|
|
- login = "11111111111"
|
|
|
- password = "Sharix!"
|
|
|
+ login = "79999999999"
|
|
|
+ password = "12345"
|
|
|
#url = "https://user.sharix-app.org/auth/token/login/"
|
|
|
data = {
|
|
|
"password":password,
|
|
@@ -254,6 +311,28 @@ def requestGetListUser():
|
|
|
print(response.json())
|
|
|
|
|
|
|
|
|
+# def requestGetList(auth_token, url):
|
|
|
+# headers = {'Authorization': f'Token {auth_token}'}
|
|
|
+# response = requests.get(url, headers=headers)
|
|
|
+# #response = requests.get(config.API_URL+"/dbsynce/api/orders/", headers=headers)
|
|
|
+# 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)
|
|
|
+# startlist.append(orderticket)
|
|
|
+# except Exception as ex:
|
|
|
+# print(ex)
|
|
|
+# print (startlist)
|
|
|
+# return startlist
|
|
|
+
|
|
|
+
|
|
|
def requestGetList(auth_token, url):
|
|
|
headers = {'Authorization': f'Token {auth_token}'}
|
|
|
response = requests.get(url, headers=headers)
|
|
@@ -267,11 +346,32 @@ def requestGetList(auth_token, url):
|
|
|
for i in ordertext:
|
|
|
print (i, "PROCESSING")
|
|
|
try:
|
|
|
- orderticket = OrderTicket(**i)
|
|
|
- print(i, "ORDER ", orderticket)
|
|
|
- startlist.append(orderticket)
|
|
|
+ order = Order(**i)
|
|
|
+ print(i, "ORDER ", order)
|
|
|
+ startlist.append(order)
|
|
|
except Exception as ex:
|
|
|
print(ex)
|
|
|
print (startlist)
|
|
|
return startlist
|
|
|
|
|
|
+class answer(object):
|
|
|
+ def __init__(self,order_id,provider,answer):
|
|
|
+ self.order_id = order_id
|
|
|
+ self.provider = provider
|
|
|
+ self.answer = answer
|
|
|
+
|
|
|
+def to_answer(jsonstring):
|
|
|
+ json_answer = json.loads(jsonstring)
|
|
|
+ print(json_answer)
|
|
|
+ u = answer(**json_answer)
|
|
|
+ return u
|
|
|
+
|
|
|
+def change_to_task(localtask,token):
|
|
|
+ headers = {
|
|
|
+ 'Authorization': f'Token {token}',
|
|
|
+ 'Content-Type': 'application/json' # Установка заголовка Content-Type
|
|
|
+ }
|
|
|
+ data = json.dumps(localtask.__dict__)
|
|
|
+ print(data)
|
|
|
+ response = requests.patch(config.API_URL+f"/dbsynce/api/orders/{localtask.id}/", headers=headers, data=data)
|
|
|
+ return response
|