generated from NHSDigital/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5323197
commit f55b37c
Showing
9 changed files
with
128 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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,78 @@ | ||
import requests | ||
from constants import api_constants | ||
|
||
|
||
class api_operations: | ||
@staticmethod | ||
def api_get(endpoint, header, param): | ||
if header is None and param is None: | ||
resp = requests.get(url=endpoint) | ||
elif header is not None and param is None: | ||
resp = requests.get(url=endpoint, headers=header) | ||
elif header is None and param is not None: | ||
resp = requests.get(url=endpoint, params=param) | ||
else: | ||
resp = requests.get(url=endpoint, params=param, headers=header) | ||
assert api_operations.__verify_response_code(resp.status_code), f"API GET failed for {endpoint}." | ||
return resp | ||
|
||
@staticmethod | ||
def api_post(endpoint, header, payload, param): | ||
resp = None | ||
if header is None and payload is None and param is None: | ||
resp = requests.post(url=endpoint) | ||
elif header is not None and payload is None and param is None: | ||
resp = requests.post(url=endpoint, headers=header) | ||
elif header is not None and payload is None and param is not None: | ||
resp = requests.post(url=endpoint, headers=header, params=param) | ||
elif header is None and payload is not None and param is None: | ||
resp = requests.post(url=endpoint, json=payload) | ||
elif header is None and payload is not None and param is not None: | ||
resp = requests.post(url=endpoint, json=payload, params=param) | ||
elif header is not None and payload is not None and param is None: | ||
resp = requests.post(url=endpoint, json=payload, headers=header) | ||
elif header is not None and payload is not None and param is not None: | ||
resp = requests.post(url=endpoint, json=payload, headers=header, params=param) | ||
assert api_operations.__verify_response_code(resp.status_code), f"API POST failed for {endpoint}." | ||
return resp | ||
|
||
@staticmethod | ||
def api_put(endpoint, header, payload, param): | ||
resp = None | ||
if header is None and payload is None and param is None: | ||
resp = requests.put(url=endpoint) | ||
elif header is not None and payload is None and param is None: | ||
resp = requests.put(url=endpoint, headers=header) | ||
elif header is not None and payload is None and param is not None: | ||
resp = requests.put(url=endpoint, headers=header, params=param) | ||
elif header is None and payload is not None and param is None: | ||
resp = requests.put(url=endpoint, json=payload) | ||
elif header is None and payload is not None and param is not None: | ||
resp = requests.put(url=endpoint, json=payload, params=param) | ||
elif header is not None and payload is not None and param is None: | ||
resp = requests.put(url=endpoint, json=payload, headers=header) | ||
elif header is not None and payload is not None and param is not None: | ||
resp = requests.put(url=endpoint, json=payload, headers=header, params=param) | ||
assert api_operations.__verify_response_code(resp.status_code), f"API PUT failed for {endpoint}." | ||
return resp | ||
|
||
@staticmethod | ||
def api_delete(endpoint, header, param): | ||
if header is None and param is None: | ||
resp = requests.delete(url=endpoint) | ||
elif header is not None and param is None: | ||
resp = requests.delete(url=endpoint, headers=header) | ||
elif header is None and param is not None: | ||
resp = requests.delete(url=endpoint, params=param) | ||
else: | ||
resp = requests.delete(url=endpoint, headers=header, params=param) | ||
assert api_operations.__verify_response_code(resp.status_code), f"API DELETE failed for {endpoint}." | ||
return resp | ||
|
||
@staticmethod | ||
def __verify_response_code(response_code: int) -> bool: | ||
return ( | ||
True | ||
if api_constants.API_SUCCESS_STATUS_CODE_MIN <= response_code <= api_constants.API_SUCCESS_STATUS_CODE_MAX | ||
else False | ||
) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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,17 @@ | ||
TEST_DESC_IGNORED,ORGANISATION_CODE,SCHOOL_URN,SCHOOL_NAME,NHS_NUMBER,PERSON_FORENAME,PERSON_SURNAME,PERSON_DOB,PERSON_GENDER_CODE,PERSON_POSTCODE,DATE_OF_VACCINATION,VACCINE_GIVEN,BATCH_NUMBER,BATCH_EXPIRY_DATE,ANATOMICAL_SITE,DOSE_SEQUENCE,LOCAL_PATIENT_ID,LOCAL_PATIENT_ID_URI,CARE_SETTING | ||
P_Gardasil9,R1L,110158,Eton College,9729852545,BERT,BOYES,20100811,Male,DN9 1PB,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Gardasil,R1L,110158,Eton College,9650974318,BOB,JERMEY,20100819,Male,DN38 6JP,20240514,Gardasil,123013325,20220730,Left Thigh,2,LocalPatient3,www.LocalPatient3,1 | ||
P_Cervarix,R1L,110158,Eton College,5990960948,MURRAY,MARQUARDT,20100808,Male,N8 7RE,20240514,Cervarix,123013325,20220730,Left Thigh,3,LocalPatient3,www.LocalPatient3,1 | ||
P_Gardasil9,R1L,888888,Test-Auto School,9461217986,SHEENA,HART-DAVIS,20100818,Female,HD9 2DD,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Gardasil,R1L,999999,Homeschooled,9448251165,ANDRIANA,MACLULICH,20100813,Female,DN17 1UE,20240514,Gardasil,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Cervarix,R1L,110158,Eton College,9490189804,VISHALA,MOKATE,20100817,Female,LA22 9SJ,20240514,Cervarix,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1 | ||
P_NFA,R1L,110158,Eton College,9694580307,LERON,KUFAKI,20100811,Male,ZZ99 3VZ,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Add_Not_Known,R1L,110158,Eton College,9694580307,LERON,KUFAKI,20100811,Male,ZZ99 3WZ,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Add_Not_Known2,R1L,110158,Eton College,9694580307,LERON,KUFAKI,20100811,Male,ZZ99 3CZ,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Site_LB,R1L,110158,Eton College,9694580307,LERON,KUFAKI,20100811,Male,DN34 4SE,20240514,Gardasil9,123013325,20220730,Left Buttock,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Site_RB,R1L,110158,Eton College,9460860354,MATTIE,MERRIGAN,20100831,Male,TS8 9EF,20240514,Gardasil9,123013325,20220730,Right Buttock,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Site_LT,R1L,110158,Eton College,9651751703,SARA,NOYES,20100829,Not Known,HU5 3SG,20240514,Gardasil9,123013325,20220730,Left Thigh,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Site_N_Should_Fail,R1L,110158,Eton College,9726851416,NAOMI,DILLON,20100818,Female,BH25 6ST,20240514,Gardasil9,123013325,20220730,Nasal,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Site_LUA,R1L,110158,Eton College,5991336512,HARLEY,PHILLIPS,20100821,Female,ZZ99 3AZ,20240514,Gardasil9,123013325,20220730,Left Upper Arm,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Site_RUA,R1L,110158,Eton College,9454468014,GIDEON,CREAN,20100830,Male,NE39 1AD,20240514,Gardasil9,123013325,20220730,Right Upper Arm,1,LocalPatient3,www.LocalPatient3,1 | ||
P_Site_RT,R1L,110158,Eton College,9686147837,JEFF,GREENE,20100808,Male,SK16 4HT,20240514,Gardasil9,123013325,20220730,Right Thigh,1,LocalPatient3,www.LocalPatient3,1 |
This file contains 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