Skip to content
Snippets Groups Projects
Commit 1e0ecba0 authored by dhana surya's avatar dhana surya
Browse files

reset the file to clear & start again

parent 104c8f18
No related branches found
No related tags found
No related merge requests found
import requests
class DataManager:
#This class is responsible for talking to the Google Sheet.
def __init__(self):
self.api_url = "https://api.sheety.co/6198e13262139b75b0b7a1fd402e2594/flightDeals/prices"
self.sheet_data = None
def fetch_data(self):
response = requests.get(
url=self.api_url,
)
response.raise_for_status()
self.sheet_data = response.json()['prices']
return self.sheet_data
def update_row(self , row_id , row_data):
self.row_id = row_id
self.row_data = row_data
json_data = {
"price": {
"id" : self.row_id,
"iataCode": self.row_data
}
}
response = requests.put(
url=f"{self.api_url}/{self.row_id}",
json=json_data
)
print(response.json())
\ No newline at end of file
from pprint import pprint
from data_manager import DataManager
#This file will need to use the DataManager,FlightSearch, FlightData, NotificationManager classes to achieve the program requirements.
data_manager = DataManager()
sheet_data = data_manager.fetch_data()
for i in range(len(sheet_data)):
data_in_sheet = sheet_data[i]
if data_in_sheet['iataCode'] == "" :
data_in_sheet['iataCode'] = "TESTING"
data_manager.update_row(
data_in_sheet['id'] ,
data_in_sheet['iataCode']
)
continue
pprint(sheet_data)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment