@@ -131,18 +131,17 @@ def set_configaration(self,config):
131
131
mconfig .validate_merchant_details (config , mconfig )
132
132
133
133
# Calling the authentication header
134
- def call_authentication_header (self , resource_path , method , header_params , body ):
134
+ def call_authentication_header (self ,method , header_params , body ):
135
135
136
136
# give the URL path to where the data needs to be authenticated
137
137
url = GlobalLabelParameters .HTTP_URL_PREFIX
138
-
139
- time = mconfig .get_time ()
138
+
139
+ time = mconfig .get_time () # mconfig.get_time()
140
140
141
141
mconfig .request_type_method = method
142
- mconfig .request_target = resource_path
143
142
144
143
mconfig .url = url + mconfig .request_host + mconfig .request_target
145
- if method .upper () == GlobalLabelParameters .POST or method .upper () == GlobalLabelParameters .PUT :
144
+ if method .upper () == GlobalLabelParameters .POST or method .upper () == GlobalLabelParameters .PUT or method . upper () == GlobalLabelParameters . PATCH :
146
145
mconfig .request_json_path_data = body
147
146
148
147
logger = mconfig .log
@@ -155,7 +154,7 @@ def call_authentication_header(self, resource_path, method, header_params, body)
155
154
header_params ["Date" ] = time
156
155
header_params ["Host" ] = mconfig .request_host
157
156
header_params ["User-Agent" ] = GlobalLabelParameters .USER_AGENT_VALUE
158
- if method .upper () == GlobalLabelParameters .POST or method .upper () == GlobalLabelParameters .PUT :
157
+ if method .upper () == GlobalLabelParameters .POST or method .upper () == GlobalLabelParameters .PUT or method . upper () == GlobalLabelParameters . PATCH :
159
158
'''print((ast.literal_eval(json.dumps(self.del_none(json.loads(body))))))'''
160
159
digest_header = self .set_digest ((body ))
161
160
@@ -168,7 +167,6 @@ def call_authentication_header(self, resource_path, method, header_params, body)
168
167
token = "Bearer " + token .decode ("utf-8" )
169
168
header_params ['Authorization' ] = str (token )
170
169
171
-
172
170
# Set the digest
173
171
def set_digest (self , body ):
174
172
digest_obj = DigestAndPayload ()
@@ -178,6 +176,21 @@ def set_digest(self, body):
178
176
179
177
return encoded_digest
180
178
179
+ # Adds query param to URL
180
+ def set_query_params (self , path , query_param ):
181
+ query_param = dict (query_param )
182
+ if query_param :
183
+ first_query_param = True
184
+ for param in query_param :
185
+
186
+ if (not first_query_param ):
187
+ path = path + "&" + param + "=" + str (query_param [param ])
188
+ else :
189
+ path = path + "?" + param + "=" + str (query_param [param ])
190
+ first_query_param = False
191
+
192
+ return path
193
+
181
194
def __call_api (self , resource_path , method ,
182
195
path_params = None , query_params = None , header_params = None ,
183
196
body = None , post_params = None , files = None ,
@@ -254,7 +267,7 @@ def __call_api(self, resource_path, method,
254
267
else :
255
268
callback ((return_data , response_data .status , response_data .getheaders ()))
256
269
elif _return_http_data_only :
257
- return (return_data ,response_data .status , response_data .data )
270
+ return (return_data , response_data .status , response_data .data )
258
271
else :
259
272
return (return_data , response_data .status , response_data .getheaders ())
260
273
@@ -370,10 +383,15 @@ def call_api(self, resource_path, method,
370
383
response_type = None , auth_settings = None , callback = None ,
371
384
_return_http_data_only = None , collection_formats = None , _preload_content = True ,
372
385
_request_timeout = None ):
373
- if method .upper () == GlobalLabelParameters .POST :
386
+ if method .upper () == GlobalLabelParameters .POST or method . upper () == GlobalLabelParameters . PUT or method . upper () == GlobalLabelParameters . PATCH :
374
387
request_body = self .replace_underscore (json .loads (body ))
375
388
body = json .dumps (request_body )
376
- self .call_authentication_header (resource_path , method , header_params , body )
389
+ query_param_path = self .set_query_params (resource_path , query_params )
390
+ if query_param_path :
391
+ mconfig .request_target = query_param_path
392
+ else :
393
+ mconfig .request_target = resource_path
394
+ self .call_authentication_header (method , header_params , body )
377
395
"""
378
396
Makes the HTTP request (synchronous) and return the deserialized data.
379
397
To make an async request, define a function for callback.
0 commit comments