-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextractpractice3.py
More file actions
74 lines (58 loc) · 3.24 KB
/
Copy pathextractpractice3.py
File metadata and controls
74 lines (58 loc) · 3.24 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import requests
import json
class MakeApiCall:
def get_data(self, url):
# response = requests.get(f"{api}", headers= headers)
headers = {
"Accept": "application/json",
"keyid": "5e5951bf-ebde-443e-a40d-a4e24c4b9103"
}
response = requests.get(f"{url}", headers=headers)
if response.status_code == 200:
print("sucessfully fetched the data")
#self.formatted_print(response.json())
return response.json()
else:
print(
f"Hello person, there's a {response.status_code} error with your request")
return []
def Central_method(self, obj):
industries = list(self.get_data(obj))
# print(industries)
length = len(industries)
for industry in industries:
nodeId = (industry["nodeID"])
productLineUrl = "https://webapi.vermeer.com/integrations/external/vcom/v1/industries/"+str(nodeId)+"?documentculture=en-us®ions=NorthAmerica"
productLines = list(self.get_data(productLineUrl))
for productLine in productLines:
industryPls = list(productLine["industryProductLines"])
for industryPl in industryPls:
rightNodeId = industryPl["rightNodeId"]
#print(rightNodeId)
productUrl = "https://webapi.vermeer.com/integrations/external/vcom/v1/product-lines/"+str(rightNodeId)+"?documentculture=en-us®ions=NorthAmerica"
products = list(self.get_data(productUrl))
#print((products))
for product in products:
productDetails = list(product["products"])
for productDetail in productDetails:
productDetailId = productDetail["nodeID"]
#print(productDetailId)
prductDetailUrl = "https://webapi.vermeer.com/integrations/external/vcom/v1/products/"+str(productDetailId)+"?documentculture=en-us®ions=NorthAmerica"
pdDetails = list(self.get_data(prductDetailUrl))
#print((pdDetails))
for pdDetail in pdDetails:
eqipId = (pdDetail["equipmentID"])
#print(eqipId)
pdSpecificationUrl = "https://webapi.vermeer.com/integrations/external/vcom/v1/equipment/"+str(eqipId)+"/specifications?cmsLanguageID=1&displayFilter=0"
#print(pdSpecificationUrl)
pdSpecification = list(self.get_data(pdSpecificationUrl))
print(pdSpecification)
#print(productLineUrl)
print("******************************************************")
# print(length)
def __init__(self, api):
self.Central_method(api)
if __name__ == "__main__":
api_call = MakeApiCall(
"https://webapi.vermeer.com/integrations/external/vcom/v1/industries?documentculture=en-us®ions=NorthAmerica")
# api_call1 = MakeApiCall("https://webapi.vermeer.com/integrations/external/vcom/v1/industries/7196?documentculture=en-us®ions=NorthAmerica")