|
@@ -1,15 +1,49 @@
|
|
import json
|
|
import json
|
|
import requests
|
|
import requests
|
|
#Тестовый класс User и Address (ВАЖНО!!!) поля классов должны называться также как и поля json объекта
|
|
#Тестовый класс User и Address (ВАЖНО!!!) поля классов должны называться также как и поля json объекта
|
|
-class Address(object):
|
|
|
|
- def __init__(self, street, number):
|
|
|
|
- self.street = street
|
|
|
|
- self.number = number
|
|
|
|
|
|
|
|
- def __str__(self):
|
|
|
|
- return "{0} {1}".format(self.street, self.number)
|
|
|
|
|
|
|
|
-class User(object):
|
|
|
|
|
|
+#{
|
|
|
|
+#
|
|
|
|
+# "ticket": null,
|
|
|
|
+# "state": "",
|
|
|
|
+# "id_metaservice": null,
|
|
|
|
+# "is_global": false,
|
|
|
|
+# "is_visible": false,
|
|
|
|
+# "service": null,
|
|
|
|
+# "service_type": null,
|
|
|
|
+#
|
|
|
|
+# "time_placed": null,
|
|
|
|
+# "time_start": null,
|
|
|
|
+# "time_start_predicted": null
|
|
|
|
+# "time_finish_predicted": null,
|
|
|
|
+# "time_start_real":
|
|
|
|
+# "time_finish_real": null,
|
|
|
|
+#
|
|
|
|
+# "order_place_start": "р-н Беговой",
|
|
|
|
+# "order_place_start_gps": "р-н Беговой",
|
|
|
|
+# "order_place_start_real": "р-н Беговой",
|
|
|
|
+# "order_place_start_real_gps": "р-н Беговой",
|
|
|
|
+# "order_place_finish_predicted": "р-н Мещанский",
|
|
|
|
+# "order_place_finish_predicted_gps": "р-н Мещанский",
|
|
|
|
+# "order_place_finish_real": "р-н Мещанский",
|
|
|
|
+# "order_place_finish_real_gps": "р-н Мещанский",
|
|
|
|
+#
|
|
|
|
+# "predicted_price": null,
|
|
|
|
+# "real_price": null,
|
|
|
|
+# "payment_transaction_id"
|
|
|
|
+# "rating_id"
|
|
|
|
+#
|
|
|
|
+# "provider": null,
|
|
|
|
+# "provider_screen_name": null
|
|
|
|
+# "receiver": null,
|
|
|
|
+# "receiver_screen_name": nulll
|
|
|
|
+# "client_id": null
|
|
|
|
+# "resource_id"
|
|
|
|
+#}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class Order(object):
|
|
def __init__(self, name, address):
|
|
def __init__(self, name, address):
|
|
self.name = name
|
|
self.name = name
|
|
self.address = Address(**address)
|
|
self.address = Address(**address)
|
|
@@ -18,10 +52,10 @@ class User(object):
|
|
return "{0} ,{1}".format(self.name, self.address)
|
|
return "{0} ,{1}".format(self.name, self.address)
|
|
|
|
|
|
#Функция преобразования json в объект класса
|
|
#Функция преобразования json в объект класса
|
|
-def jsonToUser(jsonstring) -> User:
|
|
|
|
|
|
+def jsonToClass(jsonstring) -> Order:
|
|
jsonObj = json.loads(jsonstring)
|
|
jsonObj = json.loads(jsonstring)
|
|
print(jsonObj)
|
|
print(jsonObj)
|
|
- u = User(**jsonObj)
|
|
|
|
|
|
+ u = Order(**jsonObj)
|
|
return u
|
|
return u
|
|
|
|
|
|
#Функция обращения к апи и получение токена
|
|
#Функция обращения к апи и получение токена
|
|
@@ -55,3 +89,13 @@ def requestGetListUser():
|
|
response = requests.get(url, headers=headers)
|
|
response = requests.get(url, headers=headers)
|
|
print(response)
|
|
print(response)
|
|
print(response.json())
|
|
print(response.json())
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def requestGetList(token, url):
|
|
|
|
+ #auth_token=requestGetToken()
|
|
|
|
+ #print(auth_token)
|
|
|
|
+ headers = {'Authorization': f'Token {auth_token}'}
|
|
|
|
+ #url = 'https://user.sharix-app.org/platform/api/sharix-users/'
|
|
|
|
+ response = requests.get(url, headers=headers)
|
|
|
|
+ print(response)
|
|
|
|
+ print(response.json())
|