-
Notifications
You must be signed in to change notification settings - Fork 70
Paper, Ruthie Newman #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RuthieRNewman
wants to merge
4
commits into
AdaGold:main
Choose a base branch
from
RuthieRNewman:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1c31237
Populates main.py with user option list function, user selection func…
RuthieRNewman 4cafba7
Adds customer_requests.py file for customer requests and video_reques…
RuthieRNewman b62c4f0
Adds requests rental_requests.py.
RuthieRNewman b303087
Adds edits to main.py
RuthieRNewman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| // Use IntelliSense to learn about possible attributes. | ||
| // Hover to view descriptions of existing attributes. | ||
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "name": "Python: Current File", | ||
| "type": "python", | ||
| "request": "launch", | ||
| "program": "${file}", | ||
| "console": "integratedTerminal" | ||
| } | ||
| ] | ||
| } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import requests | ||
|
|
||
| class CustomerRequests: | ||
| def __init__(self, url="http://localhost:5000", selected_customer=None): | ||
| self.url = url | ||
| self.selected_customer = selected_customer | ||
|
|
||
| def create_customer(self, name=None, postal_code=None, phone=None): | ||
|
|
||
| query_params = { | ||
| "name" : name, | ||
| "postal_code" : postal_code, | ||
| "phone": phone | ||
| } | ||
|
|
||
| response = requests.post(self.url+f"/customers",json=query_params) | ||
| return response.json() | ||
|
|
||
| def list_all_customers(self): | ||
| response = requests.get(self.url+"/customers") | ||
| return response.json() | ||
|
|
||
| def get_specific_customer(self, name=None, id=None): | ||
|
|
||
| for customer in self.list_all_customers(): | ||
|
|
||
| if name: | ||
| if name == customer["name"]: | ||
| id = customer["id"] | ||
| self.selected_customer = customer | ||
|
|
||
| elif id == customer["id"]: | ||
| self.selected_customer = customer | ||
|
|
||
| if not self.selected_customer: | ||
| print("That customer name or id could not be found") | ||
|
|
||
| return self.selected_customer | ||
|
|
||
| def update_customer(self, name=None, postal_code=None, phone=None): | ||
|
|
||
| if not name: | ||
| name = self.selected_customer["name"] | ||
|
|
||
| if not postal_code: | ||
| postal_code = self.selected_customer["postal_code"] | ||
|
|
||
| if not phone: | ||
| phone = self.selected_customer["phone"] | ||
|
|
||
| query_params = { | ||
| "name": name, | ||
| "postal_code": postal_code, | ||
| "phone": phone | ||
| } | ||
|
|
||
| response = requests.put( | ||
| self.url+f"/customers/{self.selected_customer['id']}", | ||
| json=query_params | ||
| ) | ||
|
|
||
| self.selected_customer = response.json() | ||
| return response.json() | ||
|
|
||
| def delete_customer(self): | ||
| response = requests.delete(self.url+f"/customers/{self.selected_customer['id']}") | ||
| self.selected_customer = None | ||
| return response.json() | ||
|
|
||
| def print_customer(self): | ||
| if self.selected_customer: | ||
| print(f"Customer with id {self.selected_customer['id']} is currently selected\n") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file &
__pycache__should be in your.gitignorefile. You should also addvenvto your .gitignore file as well.