Skip to content

Commit

Permalink
New input parameter to the POST method added.
Browse files Browse the repository at this point in the history
  • Loading branch information
rumen-vasilev committed Dec 18, 2024
1 parent bcad4ce commit 02b50b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/cert_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
auth_method="certificate", verify_ssl=True)

# Calls the API
api_desc_post = client.get("about/api/description", "extended=false&method=POST")
api_desc_post = client.get(endpoint="about/api/description", params="extended=false&method=POST")
if api_desc_post:
print(api_desc_post)
else:
Expand Down
11 changes: 6 additions & 5 deletions qrs_api_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,32 @@ def _request(self, method: str, endpoint: str, **kwargs) -> dict:
print(f"API request error: {e}")
return None

def get(self, endpoint: str, params=None) -> dict:
def get(self, endpoint: str, params: str = None) -> dict:
"""
Executes a GET request to the QRS API.
Args:
endpoint (str): The API endpoint to call.
params (dict, optional): Query parameters to include in the request.
params (str, optional): Query parameters to include in the request.
Returns:
dict: JSON response as a dictionary or None if an error occurs.
"""
return self._request("GET", endpoint, params=params)

def post(self, endpoint: str, data=None) -> dict:
def post(self, endpoint: str, params: str = None, data=None) -> dict:
"""
Executes a POST request to the QRS API.
Args:
endpoint (str): The API endpoint to call.
params (str, optional): Query parameters to include in the request.
data (dict or str, optional): The JSON payload to include in the request body.
Returns:
dict: JSON response as a dictionary or None if an error occurs.
"""
return self._request("POST", endpoint, data=data)
return self._request("POST", endpoint, params=params, data=data)

def delete(self, endpoint: str) -> dict:
"""
Expand Down Expand Up @@ -155,4 +156,4 @@ def create_reload_task(self, app_id, task_name, custom_properties=None, tags: li
payload = json.dumps(reload_task_bundle)

# Execute API call
return self.post("reloadtask/create", data=payload)
return self.post(endpoint="reloadtask/create", data=payload)

0 comments on commit 02b50b3

Please sign in to comment.