-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrrt.py
40 lines (32 loc) · 1.58 KB
/
rrt.py
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
35
36
37
38
from tms_assigned import Tms_task
import requests
from requests.auth import HTTPBasicAuth
import json
import pandas as pd
class showRes():
def __init__(self):
URL = "http://res.sonusnet.com/Web/Services/Authentication/Authenticate"
#r = requests.post(url = URL, json={"username":'ayadav',"password":'Welcome@456'})
r = requests.post(url = URL, json={"username":Tms_task.username,"password":Tms_task.password})
data = r.json()
keys = ('Resource','StartDate','EndDate')
resource = dict.fromkeys(keys)
sessionToken = data['sessionToken']
userId = data['userId']
getResources = "http://res.sonusnet.com/Web/Services/index.php/Reservations/?userId="+str(userId)
allResources = requests.get(url = getResources,headers={'X-Booked-SessionToken':str(sessionToken), 'X-Booked-UserId':str(userId)},data={'userId':userId})
userResourcesJSON = json.loads(allResources.content)
userReslist = userResourcesJSON['reservations']
for re in userReslist:
if resource['Resource'] == None:
resource['Resource'] = [re['resourceName']]
resource['StartDate'] = [re['startDate']]
resource['EndDate'] = [re['endDate']]
else:
resource['Resource'].append(re['resourceName'])
resource['StartDate'].append(re['startDate'])
resource['EndDate'].append(['endDate'])
dfs = pd.DataFrame.from_dict(userReslist)
self.userResources = dfs
def getResourcesData(self):
return self.userResources