Skip to content

Commit

Permalink
Create data_manager.py
Browse files Browse the repository at this point in the history
  • Loading branch information
xnkit69 committed Sep 21, 2023
1 parent 88e4273 commit 289b054
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions day40 /data_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import requests

SHEETY_PRICES_ENDPOINT = "https://api.sheety.co/********************************/flightDeals/prices/"
SHEETY_USERS_ENDPOINT = "https://api.sheety.co/*********************************/flightDeals/users"


class DataManager:

def __init__(self):
self.destination_data = {}

def get_destination_data(self):
response = requests.get(url=SHEETY_PRICES_ENDPOINT)
data = response.json()
self.destination_data = data["prices"]
return self.destination_data

def update_destination_codes(self):
for city in self.destination_data:
new_data = {
"price": {
"iataCode": city["iataCode"]
}
}
response = requests.put(
url=f"{SHEETY_PRICES_ENDPOINT}/{city['id']}",
json=new_data
)
print(response.text)

def get_customer_emails(self):
customers_endpoint = SHEETY_USERS_ENDPOINT
response = requests.get(url=customers_endpoint)
data = response.json()
self.customer_data = data["users"]
return self.customer_data

0 comments on commit 289b054

Please sign in to comment.