From e49d3d0a01ace1ee4f12183f44a9eed6be6e6e11 Mon Sep 17 00:00:00 2001 From: Norm Rasmussen Date: Sat, 31 Aug 2024 08:26:18 -0400 Subject: [PATCH] Added the create project and item functions for the mark a course as completed app. Reorganized a bit and added classes for the project as well. --- Scripts/Migration_tool/Calls.py | 14 +++- .../Mark_Course_As_Complete/Apikeys.py | 1 + .../Mark_Course_As_Complete/Calls.py | 60 +++++++++++++++ .../__pycache__/Apikeys.cpython-310.pyc | Bin 0 -> 223 bytes .../__pycache__/Calls.cpython-310.pyc | Bin 0 -> 1719 bytes .../mark_course_as_complete.py | 69 +++++++++++++++++- .../__pycache__/Calls.cpython-310.pyc | Bin 1254 -> 1459 bytes .../Migration_tool/migration_playground.py | 13 ++++ 8 files changed, 152 insertions(+), 5 deletions(-) create mode 100644 Scripts/Migration_tool/Mark_Course_As_Complete/Apikeys.py create mode 100644 Scripts/Migration_tool/Mark_Course_As_Complete/Calls.py create mode 100644 Scripts/Migration_tool/Mark_Course_As_Complete/__pycache__/Apikeys.cpython-310.pyc create mode 100644 Scripts/Migration_tool/Mark_Course_As_Complete/__pycache__/Calls.cpython-310.pyc diff --git a/Scripts/Migration_tool/Calls.py b/Scripts/Migration_tool/Calls.py index 5773dc26..ce6ee2df 100644 --- a/Scripts/Migration_tool/Calls.py +++ b/Scripts/Migration_tool/Calls.py @@ -25,7 +25,7 @@ def get(url): def post(url, payload): try: - post_response = requests.get(url, headers=HEADERS, json=payload) + post_response = requests.post(url, headers=HEADERS, json=payload) print(f"Executed Post Request. Status code is {get_response.status_code}") except HTTPError as h: print( @@ -34,3 +34,15 @@ def post(url, payload): finally: json_post = get_response.json() # PP.pprint(json_post) + + +def delete(url): + try: + get_response = requests.delete(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: + return get_response diff --git a/Scripts/Migration_tool/Mark_Course_As_Complete/Apikeys.py b/Scripts/Migration_tool/Mark_Course_As_Complete/Apikeys.py new file mode 100644 index 00000000..4cadaafe --- /dev/null +++ b/Scripts/Migration_tool/Mark_Course_As_Complete/Apikeys.py @@ -0,0 +1 @@ +SANDBOX = "SlpQlju219WnWogn94dQUT6Yt" diff --git a/Scripts/Migration_tool/Mark_Course_As_Complete/Calls.py b/Scripts/Migration_tool/Mark_Course_As_Complete/Calls.py new file mode 100644 index 00000000..14cc863b --- /dev/null +++ b/Scripts/Migration_tool/Mark_Course_As_Complete/Calls.py @@ -0,0 +1,60 @@ +import requests +import Apikeys +import pprint +import json + + +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}") + # if post_response.status_code == 404: + # print(f"Received 404 Response. Here's the returned text: {post_response.text}") + except HTTPError 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() + # PP.pprint(json_post) + return json_post + except JSONDecodeError as j: + print( + f"Error occurred. Here's the info: {h} and status code: {post_response.status_code}" + ) + return post_response + finally: + pass + + +def delete(url): + try: + get_response = requests.delete(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: + return get_response diff --git a/Scripts/Migration_tool/Mark_Course_As_Complete/__pycache__/Apikeys.cpython-310.pyc b/Scripts/Migration_tool/Mark_Course_As_Complete/__pycache__/Apikeys.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f65ef317c070c78cb28531733a9e6389be1c5a74 GIT binary patch literal 223 zcmd1j<>g`kf`1H`)6{_UV-N=!FakLaKwQiLBvKfn7*ZI688n%qB!hDb0&}uTjSMZr z^TPAf^DIqL0z*U0B1`-<8E>%%JNmge`A4i|C}INY0~5bu^+StOi;DI0@{4kd5{q+7 zi;Gk9^j-3kOLJ56N{aQv^NX_egOiIg3xFKo%=DtflFa%nm9DU!!qU?C*{L-T0 s)Og2YAS<^ZC$%J1-?1PwJGHV{ub}c4hfQvNN@-529mvVWAZs}o07zp#2LJ#7 literal 0 HcmV?d00001 diff --git a/Scripts/Migration_tool/Mark_Course_As_Complete/__pycache__/Calls.cpython-310.pyc b/Scripts/Migration_tool/Mark_Course_As_Complete/__pycache__/Calls.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..089c22ca2ac4935be17d8f6285712e6499598925 GIT binary patch literal 1719 zcma)6OK%%D5aw$ivK~>Kv?%%jwwI=hz*f#@5j)a|3NmJ#aQYNSj=*C#@;DP7cYY(0&)ulP zJ?=k2(F(8d6&S0$%4;yzIPRga{sJG*mO

CLzgd zgEZ0LT+{PR9(vApLR@%55pyBc@uwXrQyHX# z!AwfQ*Mn^##T6Ckp$JCF!*nA!UJc@e2TI3!rh-Ar#YPZ%g)haAGoiF9=p&&EZ@bgp z>g@K4%J%KsT^qD;GC4|gQ7w=5&C!Bccv(Sba#GabWM2xErHK*+9!9?L_F?rok{1E6 zcY=#jJ>_H~+0S~p|4-``AU zQi*-zaW-$wqScedJlnsy!m~I=Rmy6kntVy7Gw_@0YEJ0$T6qNHxu>1 z2(xiM>Uq)F48NXc`0)Q_I3Hm-Tj=bBM4HErUehWsnWr2DXjIN_eOHT zNCna{Ck*PLFQJa0f@QE@R?KqMn3^%>#@V>hg&%sicD97kofTy0$_6+iFN^1sH0Dv= zoPRAqX~>K!R)WS+;IS29X;w|xOJF{NuC~E2(8^`ppi7#0%p4!Pgm{f(v&v4Iln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