Skip to content

Commit 293ad98

Browse files
Bug fix/version handling (#3)
* Update version to 0.1.2 in pyproject.toml, __init__.py, and uv.lock; modify endpoint in AppDefinitionClient and enhance error logging in client methods Signed-off-by: Rishabh Verma <rishabh.v@clappia.com> * Update version to 0.1.4 in pyproject.toml, __init__.py, and uv.lock Signed-off-by: Rishabh Verma <rishabh.v@clappia.com> --------- Signed-off-by: Rishabh Verma <rishabh.v@clappia.com>
1 parent aa0e635 commit 293ad98

File tree

6 files changed

+33
-22
lines changed

6 files changed

+33
-22
lines changed

clappia_tools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .client.app_management_client import AppManagementClient
1010
from .client.submission_client import SubmissionClient
1111

12-
__version__ = "0.1.1"
12+
__version__ = "0.1.4"
1313
__all__ = ["ClappiaClient", "AppDefinitionClient", "AppManagementClient", "SubmissionClient"]
1414

1515

clappia_tools/client/app_definition_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ def get_definition(self, app_id: str, language: str = "en",
4747

4848
success, error_message, response_data = self.api_utils.make_request(
4949
method="GET",
50-
endpoint="appdefinition-external/getAppDefinition",
50+
endpoint="appdefinitionv2/getAppDefinition",
5151
params=params,
5252
)
5353

5454
if not success:
55+
logger.error(f"Error: {error_message}")
5556
return f"Error: {error_message}"
5657

58+
5759
app_info = {
5860
"appId": response_data.get("appId") if response_data else None,
5961
"version": response_data.get("version") if response_data else None,

clappia_tools/client/app_management_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def create_app(self, app_name: str, requesting_user_email_address: str,
8787
)
8888

8989
if not success:
90+
logger.error(f"Error: {error_message}")
9091
return f"Error: {error_message}"
92+
9193

9294
app_id = response_data.get("appId") if response_data else None
9395
app_url = response_data.get("appUrl") if response_data else None
@@ -259,8 +261,10 @@ def add_field(self, app_id: str, requesting_user_email_address: str,
259261
)
260262

261263
if not success:
264+
logger.error(f"Error: {error_message}")
262265
return f"Error: {error_message}"
263266

267+
264268
field_name = response_data.get("fieldName") if response_data else None
265269
result = f"Successfully added field.\nField Name: {field_name}\n\nFULL RESPONSE:\n{json.dumps(response_data, indent=2)}"
266270
return result
@@ -445,6 +449,7 @@ def update_field(self, app_id: str, requesting_user_email_address: str, field_na
445449
)
446450

447451
if not success:
452+
logger.error(f"Error: {error_message}")
448453
return f"Error: {error_message}"
449454

450455
updated_properties = []

clappia_tools/client/submission_client.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SubmissionClient(BaseClappiaClient):
1414
editing, retrieving, and managing submission ownership and status.
1515
"""
1616

17-
def create_submission(self, app_id: str, data: Dict[str, Any], email: str) -> str:
17+
def create_submission(self, app_id: str, data: Dict[str, Any], requesting_user_email_address: str) -> str:
1818
"""Creates a new submission in a Clappia application with specified field data.
1919
2020
Submits form data to create a new record in the specified Clappia app.
@@ -23,7 +23,7 @@ def create_submission(self, app_id: str, data: Dict[str, Any], email: str) -> st
2323
Args:
2424
app_id: Application ID in uppercase letters and numbers format (e.g., MFX093412). Use this to specify which Clappia app to create the submission in.
2525
data: Dictionary of field data to submit. Keys should match field names from the app definition, values should match expected field types. Example: {"employee_name": "John Doe", "department": "Engineering", "salary": 75000, "start_date": "20-02-2025"}.
26-
email: Email address of the user creating the submission. This user becomes the submission owner and must have access to the specified app. Must be a valid email format.
26+
requesting_user_email_address: Email address of the user creating the submission. This user becomes the submission owner and must have access to the specified app. Must be a valid email format.
2727
2828
Returns:
2929
str: Formatted response with submission details and status
@@ -32,11 +32,11 @@ def create_submission(self, app_id: str, data: Dict[str, Any], email: str) -> st
3232
if not is_valid:
3333
return f"Error: Invalid app_id - {error_msg}"
3434

35-
if not email or not email.strip():
36-
return "Error: email is required and cannot be empty"
35+
if not requesting_user_email_address or not requesting_user_email_address.strip():
36+
return "Error: requesting_user_email_address is required and cannot be empty"
3737

38-
if not ClappiaInputValidator.validate_email(email):
39-
return "Error: email must be a valid email address"
38+
if not ClappiaInputValidator.validate_email(requesting_user_email_address):
39+
return "Error: requesting_user_email_address must be a valid email address"
4040

4141
if not isinstance(data, dict):
4242
return "Error: data must be a dictionary"
@@ -51,19 +51,20 @@ def create_submission(self, app_id: str, data: Dict[str, Any], email: str) -> st
5151
payload = {
5252
"workplaceId": self.api_utils.workplace_id,
5353
"appId": app_id.strip(),
54-
"requestingUserEmailAddress": email.strip(),
54+
"requestingUserEmailAddress": requesting_user_email_address.strip(),
5555
"data": data,
5656
}
5757

5858
logger.info(
59-
f"Creating submission for app_id: {app_id} with data: {data} and email: {email}"
59+
f"Creating submission for app_id: {app_id} with data: {data} and requesting_user_email_address: {requesting_user_email_address}"
6060
)
6161

6262
success, error_message, response_data = self.api_utils.make_request(
6363
method="POST", endpoint="submissions/create", data=payload
6464
)
6565

6666
if not success:
67+
logger.error(f"Error: {error_message}")
6768
return f"Error: {error_message}"
6869

6970
submission_id = response_data.get("submissionId") if response_data else None
@@ -72,13 +73,13 @@ def create_submission(self, app_id: str, data: Dict[str, Any], email: str) -> st
7273
"submissionId": submission_id,
7374
"status": "created",
7475
"appId": app_id,
75-
"owner": email,
76+
"owner": requesting_user_email_address,
7677
"fieldsSubmitted": len(data),
7778
}
7879

7980
return f"Successfully created submission:\n\nSUMMARY:\n{json.dumps(submission_info, indent=2)}\n\nFULL RESPONSE:\n{json.dumps(response_data, indent=2)}"
8081

81-
def edit_submission(self, app_id: str, submission_id: str, data: Dict[str, Any], email: str) -> str:
82+
def edit_submission(self, app_id: str, submission_id: str, data: Dict[str, Any], requesting_user_email_address: str) -> str:
8283
"""Edits an existing Clappia submission by updating specified field values.
8384
8485
Modifies field data in an existing submission record while preserving other field values.
@@ -88,7 +89,7 @@ def edit_submission(self, app_id: str, submission_id: str, data: Dict[str, Any],
8889
app_id: Application ID in uppercase letters and numbers format (e.g., MFX093412). Use this to specify which Clappia app contains the submission.
8990
submission_id: Unique identifier of the submission to update (e.g., HGO51464561). This identifies the specific submission record to modify.
9091
data: Dictionary of field data to update. Keys should match field names from the app definition, values should match expected field types. Only specified fields will be updated. Example: {"employee_name": "Jane Doe", "department": "Marketing", "salary": 80000, "start_date": "20-02-2025"}.
91-
email: Email address of the user requesting the edit. This user must have permission to modify the submission. Must be a valid email format.
92+
requesting_user_email_address: Email address of the user requesting the edit. This user must have permission to modify the submission. Must be a valid email format.
9293
9394
Returns:
9495
str: Formatted response with edit details and status
@@ -101,11 +102,11 @@ def edit_submission(self, app_id: str, submission_id: str, data: Dict[str, Any],
101102
if not is_valid:
102103
return f"Error: Invalid submission_id - {error_msg}"
103104

104-
if not email or not email.strip():
105-
return "Error: email is required and cannot be empty"
105+
if not requesting_user_email_address or not requesting_user_email_address.strip():
106+
return "Error: requesting_user_email_address is required and cannot be empty"
106107

107-
if not ClappiaInputValidator.validate_email(email):
108-
return "Error: email must be a valid email address"
108+
if not ClappiaInputValidator.validate_email(requesting_user_email_address):
109+
return "Error: requesting_user_email_address must be a valid email address"
109110

110111
if not isinstance(data, dict):
111112
return "Error: data must be a dictionary"
@@ -121,25 +122,26 @@ def edit_submission(self, app_id: str, submission_id: str, data: Dict[str, Any],
121122
"workplaceId": self.api_utils.workplace_id,
122123
"appId": app_id.strip(),
123124
"submissionId": submission_id.strip(),
124-
"requestingUserEmailAddress": email.strip(),
125+
"requestingUserEmailAddress": requesting_user_email_address.strip(),
125126
"data": data,
126127
}
127128

128129
logger.info(
129-
f"Editing submission {submission_id} for app_id: {app_id} with data: {data} and email: {email}"
130+
f"Editing submission {submission_id} for app_id: {app_id} with data: {data} and requesting_user_email_address: {requesting_user_email_address}"
130131
)
131132

132133
success, error_message, response_data = self.api_utils.make_request(
133134
method="POST", endpoint="submissions/edit", data=payload
134135
)
135136

136137
if not success:
138+
logger.error(f"Error: {error_message}")
137139
return f"Error: {error_message}"
138140

139141
edit_info = {
140142
"submissionId": submission_id,
141143
"appId": app_id,
142-
"requestingUser": email,
144+
"requestingUser": requesting_user_email_address,
143145
"fieldsUpdated": len(data),
144146
"updatedFields": list(data.keys()),
145147
"status": "updated",
@@ -204,6 +206,7 @@ def update_owners(self, app_id: str, submission_id: str, requesting_user_email_a
204206
)
205207

206208
if not success:
209+
logger.error(f"Error: {error_message}")
207210
return f"Error: {error_message}"
208211

209212
owners_info = {
@@ -281,6 +284,7 @@ def update_status(self, app_id: str, submission_id: str, requesting_user_email_a
281284
)
282285

283286
if not success:
287+
logger.error(f"Error: {error_message}")
284288
return f"Error: {error_message}"
285289

286290
status_info = {

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "clappia-tools"
7-
version = "0.1.1"
7+
version = "0.1.4"
88
description = "Python client for Clappia API integration"
99
readme = "README.md"
1010
requires-python = ">=3.10"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)