Updated WilliamsSonoma post-new hire templates. Made good progress on migration tool scripts.
This commit is contained in:
36
Scripts/Migration_tool/Calls.py
Normal file
36
Scripts/Migration_tool/Calls.py
Normal file
@ -0,0 +1,36 @@
|
||||
import requests
|
||||
import Apikeys
|
||||
import pprint
|
||||
|
||||
|
||||
PP = pprint.PrettyPrinter(indent=4)
|
||||
APIKEY = Apikeys.SANDBOX
|
||||
HEADERS = {"content-type": "application/json", "X-Api-Key": APIKEY}
|
||||
BASEURL = "https://api.northpass.com/v2"
|
||||
|
||||
|
||||
def get(url):
|
||||
try:
|
||||
get_response = requests.get(url, headers=HEADERS)
|
||||
# print(f"Executed Get Request. Status code is {get_response.status_code}")
|
||||
except HTTPError as h:
|
||||
print(
|
||||
f"Error occurred. Here's the info: {h} and status code: {get_response.status_code}"
|
||||
)
|
||||
finally:
|
||||
json_get = get_response.json()
|
||||
# PP.pprint(json_get)
|
||||
return json_get
|
||||
|
||||
|
||||
def post(url, payload):
|
||||
try:
|
||||
post_response = requests.get(url, headers=HEADERS, json=payload)
|
||||
print(f"Executed Post Request. Status code is {get_response.status_code}")
|
||||
except HTTPError as h:
|
||||
print(
|
||||
f"Error occurred. Here's the info: {h} and status code: {get_response.status_code}"
|
||||
)
|
||||
finally:
|
||||
json_post = get_response.json()
|
||||
# PP.pprint(json_post)
|
||||
Reference in New Issue
Block a user