11# infobip-api-python-sdk
22Python client for Infobip's API channels.
33
4+ # Supported channels
5+ - Whatsapp -> [ Docs] ( https://www.infobip.com/docs/api#channels/whatsapp )
6+ - WebRTC -> [ Docs] ( https://www.infobip.com/docs/api#channels/webrtc/ )
7+ - MMS -> [ Docs] ( https://www.infobip.com/docs/api#channels/mms )
8+
49#### Table of contents:
510
611- [ General Info] ( #general-info )
@@ -9,10 +14,6 @@ Python client for Infobip's API channels.
914- [ Code example] ( #code-example )
1015- [ Testing] ( #testing )
1116- [ Enable pre-commit hooks] ( #enable-pre-commit-hooks )
12- - [ Generating distribution package] ( #generating-distribution-package )
13- - [ Uploading distribution package on TestPyPI] ( #uploading-distribution-package-on-testpypi-for-testing-purposes )
14- - [ Installing your newly uploaded package] ( #installing-your-newly-uploaded-package )
15-
1617
1718## General Info
1819
@@ -27,7 +28,7 @@ Published under [MIT License](LICENSE).
2728## Installation
2829
2930Install the library by using the following command:
30- ```
31+ ``` bash
3132pip install infobip-api-python-sdk
3233```
3334
@@ -38,21 +39,21 @@ If you don't already have one, you can create a free trial account [here](https:
3839In this example we will show how to send WhatsApp text message.
3940First step is to import necessary channel, in this case WhatsApp channel.
4041
41- ```
42+ ``` python
4243from infobip_channels import WhatsAppChannel
4344```
4445
4546Now you can create instance of ` WhatsAppChannel ` with your ` base_url ` and ` api_key ` .
4647
47- ```
48+ ``` python
4849c = WhatsAppChannel.from_auth_params({
4950 " base_url" : " <your_base_url>" ,
5051 " api_key" : " <your_api_key>"
5152})
5253```
5354After that you can access all the methods from ` WhatsAppChannel ` .
5455To send text message you can use ` send_text_message ` method and add correct payload:
55- ```
56+ ``` python
5657response = c.send_text_message(
5758 {
5859 " from" : " <WhatsApp sender number from your Infobib account>" ,
@@ -69,89 +70,38 @@ response = c.send_text_message(
6970## Testing
7071To run tests position yourself in the project's root while your virtual environment
7172is active and run:
72- ```
73+ ``` bash
7374python -m pytest
7475```
7576
7677## Enable pre-commit hooks
7778To enable pre-commit hooks run:
78- ```
79+ ``` bash
7980pip install -r requirements/dev.txt
8081```
8182You will need to install pre-commit hooks
8283Using homebrew:
83- ```
84+ ``` bash
8485brew install pre-commit
8586```
8687Using conda (via conda-forge):
87- ```
88+ ``` bash
8889conda install -c conda-forge pre-commit
8990```
9091To check installation run:
91- ```
92+ ``` bash
9293pre-commit --version
9394```
9495If installation was successful you will see version number.
9596You can find the Pre-commit configuration in ` .pre-commit-config.yaml ` .
9697Install the git hook scripts:
97- ```
98+ ``` bash
9899pre-commit install
99100```
100101Run against all files:
101- ```
102+ ``` bash
102103pre-commit run --all-files
103104```
104105If setup was successful pre-commit will run on every commit.
105106Every time you clone a project that uses pre-commit, running ` pre-commit install `
106107should be the first thing you do.
107-
108-
109- ## Generating distribution package
110- Make sure you have the latest version of PyPA's
111- [ build] ( https://packaging.python.org/en/latest/key_projects/#build ) installed:
112- ```
113- python -m pip install --upgrade build
114- ```
115- After installation check ` setup.cfg ` file for metadata.
116- Name and version are used for file generation.
117- Make sure that you appropriately change version before build.
118- Update the ` version ` in the ` setup.cfg ` file to the desired one.
119-
120- Now run this command from the same directory where pyproject.toml is located:
121- ```
122- python -m build
123- ```
124-
125- This command should generate two files in the ` dist ` directory:
126- ```
127- dist/
128- infobip_channels-x.y.z-py3-none-any.whl
129- infobip-channels-x.y.z.tar.gz
130- ```
131-
132-
133- ## Uploading distribution package on TestPyPI (for testing purposes)
134- First thing to do is create an account on TestPyPI and acquire an API token.
135- To upload the distribution package, you can use
136- [ twine] ( https://packaging.python.org/en/latest/key_projects/#twine ) :
137- ```
138- python -m pip install --upgrade twine
139- ```
140-
141- Once installed, run Twine to upload all the archives under dist:
142- ```
143- python -m twine upload --repository testpypi dist/*
144- ```
145-
146- You will be prompted for a username and password. For the username, use * \_\_ token\_\_ * .
147- For the password, use the token value, including the pypi- prefix.
148-
149-
150- ## Installing your newly uploaded package
151- To test the newly uploaded package, create a virtual environment and download the
152- package:
153- ```
154- pip install --extra-index-url https://test.pypi.org/simple/ infobip-channels==x.y.z
155- ```
156-
157- After that, create a test script or import the library in a shell and try it out.
0 commit comments