TONS of migration progress! I'm so close
...
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
SANDBOX = "SlpQlju219WnWogn94dQUT6Yt"
|
||||
@ -0,0 +1,63 @@
|
||||
import requests
|
||||
from utils import apikeys
|
||||
import pprint
|
||||
from json import JSONDecodeError
|
||||
|
||||
|
||||
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.post(url, headers=HEADERS, json=payload)
|
||||
print(f"Executed Post Request. Status code is {post_response.status_code}")
|
||||
except TypeError as h:
|
||||
print(
|
||||
f"Error occurred. Here's the info: {h} and status code: {post_response.status_code}"
|
||||
)
|
||||
finally:
|
||||
try:
|
||||
json_post = post_response.json()
|
||||
# print(f"JSONResponse: {json_post}")
|
||||
return json_post
|
||||
except JSONDecodeError as e:
|
||||
print(f"Error occurred. Here's the info: {e}.")
|
||||
# print(f"PostResponse: {post_response}")
|
||||
return post_response
|
||||
finally:
|
||||
# PP.pprint(json_get)
|
||||
pass
|
||||
#
|
||||
# def post(url, payload):
|
||||
# post_response = requests.post(url, headers=HEADERS, json=payload)
|
||||
# print(f"Executed Post Request. Status code is {post_response.status_code}")
|
||||
# print(post_response.text)
|
||||
# return post_response
|
||||
|
||||
def delete(url):
|
||||
try:
|
||||
delete_response = requests.delete(url, headers=HEADERS)
|
||||
print(f"Executed Delete Request. Status code is {delete_response.status_code}")
|
||||
except HTTPError as h:
|
||||
print(
|
||||
f"Error occurred. Here's the info: {h} and status code: {delete_response.status_code}"
|
||||
)
|
||||
finally:
|
||||
return delete_response
|
||||
Reference in New Issue
Block a user