Skip to content

Commit a6949e0

Browse files
authored
Feature/devexp 802 python conversation api apps (#2)
* feat(conversation): apps implementation
1 parent 72cce86 commit a6949e0

186 files changed

Lines changed: 5898 additions & 79 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ jobs:
3333
run: |
3434
pip install python-dotenv
3535
python scripts/check_snippet_coverage.py
36-
37-
- name: Generate Documentation
38-
run: |
39-
make docs
4036
4137
- name: Lint and format check with Ruff
4238
run: |
@@ -79,6 +75,7 @@ jobs:
7975
cp sinch-sdk-mockserver/features/sms/* ./tests/e2e/sms/features/
8076
cp sinch-sdk-mockserver/features/number-lookup/lookups.feature ./tests/e2e/number-lookup/features/
8177
cp sinch-sdk-mockserver/features/conversation/messages.feature ./tests/e2e/conversation/features/
78+
cp sinch-sdk-mockserver/features/conversation/apps.feature ./tests/e2e/conversation/features/
8279
cp sinch-sdk-mockserver/features/conversation/webhooks-events.feature ./tests/e2e/conversation/features/
8380
8481
- name: Wait for mock server

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ All notable changes to the **Sinch Python SDK** are documented in this file.
1818

1919
## v2.2.0 – unreleased
2020

21+
### Conversation
2122

23+
- **[feature]** Conversation Apps API: `create`, `get`, `list`, `update`, and `delete` operations, with full model, endpoints and unit/e2e test coverage.
24+
- **[deprecation notice]** `ConversationProcessingMode` and `ConversationRetentionPolicyType` are deprecated; they are unused by the SDK and will be removed in 3.0.
25+
- **[deprecation notice]** `ConversationMetadataReportView` is deprecated in favour of `ConversationMetadataReportViewType`; it will be removed in 3.0.
26+
- **[deprecation notice]** `ConversationChannel` is deprecated in favour of `ConversationChannelType`; it will be removed in 3.0.
2227

2328
---
2429

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python/tree/main/examples/snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
9+
from sinch import SinchClient
10+
11+
load_dotenv()
12+
13+
sinch_client = SinchClient(
14+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
15+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
16+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET",
17+
conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION"
18+
)
19+
20+
# The display name for the app
21+
display_name = "[Python SDK: Conversation App] Sample app"
22+
23+
# The service plan ID for the SMS channel
24+
sms_service_plan_id = os.environ.get("SINCH_SERVICE_PLAN_ID") or "SMS_SERVICE_PLAN_ID"
25+
26+
# The API token for the SMS channel
27+
sms_api_token = "SMS_API_TOKEN"
28+
29+
# The channel credentials for the app
30+
channel_credentials = {
31+
"SMS": {
32+
"claimed_identity": sms_service_plan_id,
33+
"token": sms_api_token
34+
}
35+
}
36+
37+
response = sinch_client.conversation.apps.create(
38+
display_name=display_name,
39+
channel_credentials=channel_credentials,
40+
)
41+
42+
print(f"Successfully created app.\n{response}")
43+
44+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python/tree/main/examples/snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
9+
from sinch import SinchClient
10+
11+
load_dotenv()
12+
13+
sinch_client = SinchClient(
14+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
15+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
16+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET",
17+
conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION"
18+
)
19+
20+
# The ID of the app to delete
21+
app_id = "CONVERSATION_APP_ID"
22+
23+
sinch_client.conversation.apps.delete(app_id=app_id)
24+
25+
print("App deleted successfully")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python/tree/main/examples/snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
9+
from sinch import SinchClient
10+
11+
load_dotenv()
12+
13+
sinch_client = SinchClient(
14+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
15+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
16+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET",
17+
conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION"
18+
)
19+
20+
# The ID of the app to retrieve
21+
app_id = "CONVERSATION_APP_ID"
22+
23+
response = sinch_client.conversation.apps.get(app_id=app_id)
24+
25+
print(f"App details:\n{response}")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python/tree/main/examples/snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
9+
from sinch import SinchClient
10+
11+
load_dotenv()
12+
13+
sinch_client = SinchClient(
14+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
15+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
16+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET",
17+
conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION"
18+
)
19+
20+
apps = sinch_client.conversation.apps.list()
21+
22+
print("List of apps:\n")
23+
for app in apps.iterator():
24+
print(app)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Sinch Python Snippet
3+
4+
This snippet is available at https://github.com/sinch/sinch-sdk-python/tree/main/examples/snippets
5+
"""
6+
7+
import os
8+
from dotenv import load_dotenv
9+
from sinch import SinchClient
10+
11+
load_dotenv()
12+
13+
sinch_client = SinchClient(
14+
project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
15+
key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
16+
key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET",
17+
conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION"
18+
)
19+
20+
# The ID of the app to update
21+
app_id = "CONVERSATION_APP_ID"
22+
23+
# The new display name for the app
24+
display_name = "Updated from Python SDK snippet"
25+
26+
response = sinch_client.conversation.apps.update(
27+
app_id=app_id,
28+
display_name=display_name
29+
)
30+
31+
print(f"Updated app:\n{response}")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from sinch.domains.conversation.api.v1.apps_apis import Apps
12
from sinch.domains.conversation.api.v1.messages_apis import Messages
23

34
__all__ = [
45
"Messages",
6+
"Apps",
57
]

0 commit comments

Comments
 (0)