Skip to content

Commit 2c6aa74

Browse files
committed
Merge branch 'master' into infobip/ib-tjuhasz-workflows
# Conflicts: # CHANGELOG.md
2 parents a593476 + 8468ac9 commit 2c6aa74

File tree

3 files changed

+131
-4
lines changed

3 files changed

+131
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ and this library adheres to [Semantic Versioning](http://semver.org/) as mention
1010
⚠ IMPORTANT NOTE: From this point onward Python 3.7 is no longer supported. The minimum supported version is Python 3.8 due to dependency updates.
1111

1212
### Added
13-
* `snyk.yml` workflow, which serves the purpose of identifying and addressing dependency vulnerabilities in the project.
14-
* `sonar.yml` workflow to analyze the source code, enhancing code quality and maintainability.
13+
- `calls.md` which contains examples and explanations for the Calls API
14+
- `snyk.yml` workflow, which serves the purpose of identifying and addressing dependency vulnerabilities in the project.
15+
- `sonar.yml` workflow to analyze the source code, enhancing code quality and maintainability.
1516

1617
### Security
17-
* Bumped werkzeug dependency from 2.1.2 to 3.0.3
18-
* Bumped pytest-httpserver dependency from 1.0.4 to 1.0.8
18+
- Bumped werkzeug dependency from 2.1.2 to 3.0.3
19+
- Bumped pytest-httpserver dependency from 1.0.4 to 1.0.8
1920

2021
## [ [4.0.0](https://github.com/infobip/infobip-api-python-client/releases/tag/4.0.0) ] - 2024-06-13
2122
🎉 **NEW Major Version of `infobip_api_client`.**

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ Example of webhook implementation using Flask:
192192
#### Two-Factor Authentication (2FA)
193193
For 2FA quick start guide please check [these examples](two-factor-authentication.md).
194194

195+
#### Calls
196+
For Calls quick start guide please check [these_examples](calls.md)
197+
195198
## Ask for help
196199

197200
Feel free to open issues on the repository for any issue or feature request. As per pull requests, for details check the `CONTRIBUTING` [file][contributing] related to it - in short, we will not merge any pull requests, this code is auto-generated.

calls.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
## Calls
2+
Initialize Calls API client:
3+
```python
4+
from infobip_api_client.api_client import ApiClient, Configuration
5+
from infobip_api_client.api import CallsApi
6+
7+
client_config = Configuration(
8+
host="<YOUR_BASE_URL>",
9+
api_key={"APIKeyHeader": "<YOUR_API_KEY>"},
10+
api_key_prefix={"APIKeyHeader": "<YOUR_API_PREFIX>"},
11+
)
12+
13+
calls_client = ApiClient(client_config)
14+
api_instance = CallsApi(calls_client)
15+
```
16+
Before starting a call or dialogue you need to set up the application.
17+
18+
#### Start call
19+
After setting up the client you can start a call.
20+
```python
21+
from infobip_api_client.models import CallRequest, CallsPhoneEndpoint, CallEndpointType, CallState
22+
23+
request = CallRequest(
24+
endpoint=CallsPhoneEndpoint(phone_number="<TO_PHONE_NUMBER>", type=CallEndpointType.PHONE),
25+
var_from="<FROM_PHONE_NUMBER>",
26+
calls_configuration_id="ORION",
27+
)
28+
29+
api_response = api_instance.create_call(call_request=request)
30+
31+
call = api_instance.get_call(api_response.id)
32+
callId = call.id
33+
callState = call.state
34+
35+
print("Waiting for CallState to be established...")
36+
while CallState.ESTABLISHED != callState:
37+
callState = api_instance.get_call(api_response.id).state
38+
```
39+
40+
#### Executing call with text
41+
After starting a call, you can execute text to be said.
42+
```python
43+
from infobip_api_client.models import CallsSayRequest, CallsLanguage
44+
45+
call_say_request = CallsSayRequest(
46+
text="<TEXT_TO_SAY>",
47+
language=CallsLanguage.EN,
48+
)
49+
50+
api_response = api_instance.call_say_text(call_id=callId,
51+
calls_say_request=call_say_request)
52+
53+
```
54+
55+
#### Start dialogue
56+
After starting a call, you can start a dialogue.
57+
```python
58+
import time
59+
from infobip_api_client.models import CallsDialogRequest, CallsDialogCallRequest, CallsWebRtcEndpoint, CallEndpointType
60+
61+
call_dialog_request = CallsDialogRequest(
62+
parent_call_id=callId,
63+
child_call_request=CallsDialogCallRequest(
64+
endpoint=CallsWebRtcEndpoint(type=CallEndpointType.WEBRTC, identity="<YOUR_IDENTITY>"),
65+
var_from="<FROM>",
66+
)
67+
)
68+
69+
api_response = api_instance.create_dialog(calls_dialog_request=call_dialog_request)
70+
71+
time.sleep(5)
72+
73+
api_instance.hangup_dialog(api_response.id)
74+
75+
```
76+
77+
#### Starting a call for conference
78+
Before starting a conference you need to start a call.
79+
```python
80+
from infobip_api_client.models import CallRequest, CallsWebRtcEndpoint, CallEndpointType, CallState
81+
82+
request = CallRequest(
83+
endpoint=CallsWebRtcEndpoint(identity="<YOUR_IDENTITY>", type=CallEndpointType.WEBRTC),
84+
var_from="<FROM>",
85+
calls_configuration_id="ORION",
86+
)
87+
88+
api_response = api_instance.create_call(call_request=request)
89+
90+
call = api_instance.get_call(api_response.id)
91+
callId = call.id
92+
callState = call.state
93+
94+
print("Waiting for CallState to be established...")
95+
while CallState.ESTABLISHED != callState:
96+
callState = api_instance.get_call(api_response.id).state
97+
```
98+
99+
#### Start conference
100+
After starting a call, you can add it to the conference.
101+
```python
102+
import time
103+
from infobip_api_client.models import CallsConferenceRequest, CallsAddExistingCallRequest
104+
105+
conference_request = CallsConferenceRequest(
106+
name="<YOUR_CONFERENCE_NAME>",
107+
calls_configuration_id="ORION",
108+
)
109+
110+
api_response = api_instance.create_conference(calls_conference_request=conference_request)
111+
112+
conferenceId = api_response.id
113+
114+
add_existing_call_request = CallsAddExistingCallRequest()
115+
116+
api_instance.add_existing_conference_call(conference_id=conferenceId,
117+
call_id=callId,
118+
calls_add_existing_call_request=add_existing_call_request)
119+
120+
time.sleep(5)
121+
122+
api_instance.hangup_conference(conferenceId)
123+
```

0 commit comments

Comments
 (0)