@@ -7,7 +7,7 @@ class Orcid():
7
7
'''
8
8
This is a wrapper class for ORCID API
9
9
'''
10
- def __init__ (self ,orcid_id , orcid_access_token = " " , state = "public" ) -> None :
10
+ def __init__ (self ,orcid_id , orcid_access_token = " " , state = "public" , sandbox = False ) -> None :
11
11
'''
12
12
Initialize orcid instance
13
13
orcid_id : Orcid ID of the user
@@ -17,6 +17,7 @@ def __init__(self,orcid_id, orcid_access_token = " ", state="public") -> None:
17
17
self ._orcid_id = orcid_id
18
18
self ._orcid_access_token = orcid_access_token
19
19
self ._state = state
20
+ self ._sandbox = sandbox
20
21
#For testing purposes (pytesting on github workflow)
21
22
if orcid_access_token != " " :
22
23
try :
@@ -45,12 +46,14 @@ def __is_access_token_valid(self):
45
46
46
47
if self ._state == "public" :
47
48
# Specify the ORCID record endpoint for the desired ORCID iD
48
- # api_url = f'https://pub.sandbox.orcid.org/v3.0/{self._orcid_id}' #for testing
49
49
api_url = f'https://pub.orcid.org/v3.0/{ self ._orcid_id } '
50
+ if (self ._sandbox ):
51
+ api_url = f'https://pub.sandbox.orcid.org/v3.0/{ self ._orcid_id } ' #for testing
50
52
51
53
elif self ._state == "member" :
52
- # api_url = f'https://api.sandbox.orcid.org/v3.0/{self._orcid_id}' #for testing
53
54
api_url = f'https://api.orcid.org/v3.0/{ self ._orcid_id } '
55
+ if (self ._sandbox ):
56
+ api_url = f'https://api.sandbox.orcid.org/v3.0/{ self ._orcid_id } ' #for testing
54
57
55
58
response = requests .get (api_url , headers = headers )
56
59
@@ -79,12 +82,15 @@ def __read_section(self,section="record"):
79
82
80
83
if self ._state == "public" :
81
84
# Specify the ORCID record endpoint for the desired ORCID iD
82
- # api_url = f'https://pub.sandbox.orcid.org/v3.0/{self._orcid_id}' #for testing
83
85
api_url = f'https://pub.orcid.org/v3.0/{ self ._orcid_id } /{ section } '
86
+ if (self ._sandbox ):
87
+ api_url = f'https://pub.sandbox.orcid.org/v3.0/{ self ._orcid_id } /{ section } ' #for testing
84
88
85
89
elif self ._state == "member" :
86
- # api_url = f'https://api.sandbox.orcid.org/v3.0/{self._orcid_id}' #for testing
87
90
api_url = f'https://api.orcid.org/v3.0/{ self ._orcid_id } /{ section } '
91
+ if (self ._sandbox ):
92
+ api_url = f'https://api.sandbox.orcid.org/v3.0/{ self ._orcid_id } /{ section } ' #for testing
93
+
88
94
89
95
# Make a GET request to retrieve the ORCID record
90
96
response = requests .get (api_url , headers = headers )
0 commit comments