|
| 1 | +# Getting started |
| 2 | + |
| 3 | +TODO: Add a description |
| 4 | + |
| 5 | +## How to Build |
| 6 | + |
| 7 | + |
| 8 | +You must have Python ```2 >=2.7.9``` or Python ```3 >=3.4``` installed on your system to install and run this SDK. This SDK package depends on other Python packages like nose, jsonpickle etc. |
| 9 | +These dependencies are defined in the ```requirements.txt``` file that comes with the SDK. |
| 10 | +To resolve these dependencies, you can use the PIP Dependency manager. Install it by following steps at [https://pip.pypa.io/en/stable/installing/](https://pip.pypa.io/en/stable/installing/). |
| 11 | + |
| 12 | +Python and PIP executables should be defined in your PATH. Open command prompt and type ```pip --version```. |
| 13 | +This should display the version of the PIP Dependency Manager installed if your installation was successful and the paths are properly defined. |
| 14 | + |
| 15 | +* Using command line, navigate to the directory containing the generated files (including ```requirements.txt```) for the SDK. |
| 16 | +* Run the command ```pip install -r requirements.txt```. This should install all the required dependencies. |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +## How to Use |
| 22 | + |
| 23 | +The following section explains how to use the MessageMediaWebhooks SDK package in a new project. |
| 24 | + |
| 25 | +### 1. Open Project in an IDE |
| 26 | + |
| 27 | +Open up a Python IDE like PyCharm. The basic workflow presented here is also applicable if you prefer using a different editor or IDE. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +Click on ```Open``` in PyCharm to browse to your generated SDK directory and then click ```OK```. |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +The project files will be displayed in the side bar as follows: |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +### 2. Add a new Test Project |
| 40 | + |
| 41 | +Create a new directory by right clicking on the solution name as shown below: |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +Name the directory as "test" |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +Add a python file to this project with the name "testsdk" |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +Name it "testsdk" |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +In your python file you will be required to import the generated python library using the following code lines |
| 58 | + |
| 59 | +```Python |
| 60 | +from message_media_webhooks.message_media_webhooks_client import MessageMediaWebhooksClient |
| 61 | +``` |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +After this you can write code to instantiate an API client object, get a controller object and make API calls. Sample code is given in the subsequent sections. |
| 66 | + |
| 67 | +### 3. Run the Test Project |
| 68 | + |
| 69 | +To run the file within your test project, right click on your Python file inside your Test project and click on ```Run``` |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +## How to Test |
| 75 | + |
| 76 | +You can test the generated SDK and the server with automatically generated test |
| 77 | +cases. unittest is used as the testing framework and nose is used as the test |
| 78 | +runner. You can run the tests as follows: |
| 79 | + |
| 80 | + 1. From terminal/cmd navigate to the root directory of the SDK. |
| 81 | + 2. Invoke ```pip install -r test-requirements.txt``` |
| 82 | + 3. Invoke ```nosetests``` |
| 83 | + |
| 84 | +## Initialization |
| 85 | + |
| 86 | +### Authentication |
| 87 | +In order to setup authentication and initialization of the API client, you need the following information. |
| 88 | + |
| 89 | +| Parameter | Description | |
| 90 | +|-----------|-------------| |
| 91 | +| basic_auth_user_name | The username to use with basic authentication | |
| 92 | +| basic_auth_password | The password to use with basic authentication | |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +API client can be initialized as following. |
| 97 | + |
| 98 | +```python |
| 99 | +# Configuration parameters and credentials |
| 100 | +basic_auth_user_name = 'basic_auth_user_name' # The username to use with basic authentication |
| 101 | +basic_auth_password = 'basic_auth_password' # The password to use with basic authentication |
| 102 | + |
| 103 | +client = MessageMediaWebhooksClient(basic_auth_user_name, basic_auth_password) |
| 104 | +``` |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | +# Class Reference |
| 109 | + |
| 110 | +## <a name="list_of_controllers"></a>List of Controllers |
| 111 | + |
| 112 | +* [APIController](#api_controller) |
| 113 | + |
| 114 | +## <a name="api_controller"></a> APIController |
| 115 | + |
| 116 | +### Get controller instance |
| 117 | + |
| 118 | +An instance of the ``` APIController ``` class can be accessed from the API Client. |
| 119 | + |
| 120 | +```python |
| 121 | + client_controller = client.client |
| 122 | +``` |
| 123 | + |
| 124 | +### <a name="create"></a> create |
| 125 | + |
| 126 | +> This will create a webhook for the specified `events` |
| 127 | +> ### Parameters |
| 128 | +> **list of supported parameters in `template` according to the message type :** |
| 129 | +> you must escape the json for the template parameter. see example . |
| 130 | +> | Data | parameter name | DR| MO | MO MMS | Comment | |
| 131 | +> |:--|--|--|--|--|--| |
| 132 | +> | **service type** | $type| ``OK`` |`OK`| `OK`| | |
| 133 | +> | **Message ID** | $mtId, $messageId| `OK` |`OK`| `OK`| | |
| 134 | +> | **Delivery report ID** |$drId, $reportId | `OK` || | | |
| 135 | +> | **Reply ID**| $moId, $replyId| |`OK`| `OK`|| |
| 136 | +> | **Account ID** | $accountId| `OK` |`OK`| `OK`|| |
| 137 | +> | **Message Timestamp** | $submittedTimestamp| `OK` |`OK`| `OK`|| |
| 138 | +> | **Provider Timestamp** | $receivedTimestamp| `OK` |`OK`| `OK`|| |
| 139 | +> | **Message status** | $status| `OK` |||| |
| 140 | +> | **Status code** | $statusCode| `OK` |||| |
| 141 | +> | **External metadata** | $metadata.get('key')| `OK` |`OK`| `OK`|| |
| 142 | +> | **Source address**| $sourceAddress| `OK` |`OK`| `OK`|| |
| 143 | +> | **Destination address**| $destinationAddress| |`OK`| `OK`|| |
| 144 | +> | **Message content**| $mtContent, $messageContent| `OK` |`OK`| `OK`|| |
| 145 | +> | **Reply Content**| $moContent, $replyContent| |`OK`| `OK`|| |
| 146 | +> | **Retry Count**| $retryCount| `OK` |`OK`| `OK`|| |
| 147 | +> **list of allowed `events` :** |
| 148 | +> you can combine all the events whatever the message type.(at least one Event set otherwise the webhook won't be created) |
| 149 | +> + **events for SMS** |
| 150 | +> + `RECEIVED_SMS` |
| 151 | +> + `OPT_OUT_SMS` |
| 152 | +> + **events for MMS** |
| 153 | +> + `RECEIVED_MMS` |
| 154 | +> + **events for DR** |
| 155 | +> + `ENROUTE_DR` |
| 156 | +> + `EXPIRED_DR` |
| 157 | +> + `REJECTED_DR` |
| 158 | +> + `FAILED_DR` |
| 159 | +> + `DELIVERED_DR` |
| 160 | +> + `SUBMITTED_DR` |
| 161 | +> a **Response 400 is returned when** : |
| 162 | +> <ul> |
| 163 | +> <li>the `url` is not valid </li> |
| 164 | +> <li>the `events` is null/empty </li> |
| 165 | +> <li>the `encoding` is null </li> |
| 166 | +> <li>the `method` is null </li> |
| 167 | +> <li>the `headers` has a `ContentType` attribute </li> |
| 168 | +> </ul> |
| 169 | +
|
| 170 | +```python |
| 171 | +def create(self, |
| 172 | + content_type, |
| 173 | + body) |
| 174 | +``` |
| 175 | + |
| 176 | +#### Parameters |
| 177 | + |
| 178 | +| Parameter | Tags | Description | |
| 179 | +|-----------|------|-------------| |
| 180 | +| contentType | ``` Required ``` | TODO: Add a parameter description | |
| 181 | +| body | ``` Required ``` | TODO: Add a parameter description | |
| 182 | + |
| 183 | + |
| 184 | + |
| 185 | +#### Example Usage |
| 186 | + |
| 187 | +```python |
| 188 | +content_type = 'Content-Type' |
| 189 | +body = CreateRequest() |
| 190 | + |
| 191 | +result = client_controller.create(content_type, body) |
| 192 | + |
| 193 | +``` |
| 194 | + |
| 195 | +#### Errors |
| 196 | + |
| 197 | +| Error Code | Error Description | |
| 198 | +|------------|-------------------| |
| 199 | +| 400 | TODO: Add an error description | |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | + |
| 204 | +### <a name="delete_delete_and_update_webhook"></a> delete_delete_and_update_webhook |
| 205 | + |
| 206 | +> This will delete the webhook wuth the give id. |
| 207 | +> a **Response 404 is returned when** : |
| 208 | +> <ul> |
| 209 | +> <li>there is no webhook with this `webhookId` </li> |
| 210 | +> </ul> |
| 211 | +
|
| 212 | +```python |
| 213 | +def delete_delete_and_update_webhook(self, |
| 214 | + webhook_id) |
| 215 | +``` |
| 216 | + |
| 217 | +#### Parameters |
| 218 | + |
| 219 | +| Parameter | Tags | Description | |
| 220 | +|-----------|------|-------------| |
| 221 | +| webhookId | ``` Required ``` | TODO: Add a parameter description | |
| 222 | + |
| 223 | + |
| 224 | + |
| 225 | +#### Example Usage |
| 226 | + |
| 227 | +```python |
| 228 | +webhook_id = a7f11bb0-f299-4861-a5ca-9b29d04bc5ad |
| 229 | + |
| 230 | +client_controller.delete_delete_and_update_webhook(webhook_id) |
| 231 | + |
| 232 | +``` |
| 233 | + |
| 234 | +#### Errors |
| 235 | + |
| 236 | +| Error Code | Error Description | |
| 237 | +|------------|-------------------| |
| 238 | +| 404 | TODO: Add an error description | |
| 239 | + |
| 240 | + |
| 241 | + |
| 242 | + |
| 243 | +### <a name="retrieve"></a> retrieve |
| 244 | + |
| 245 | +> This will retrieve all webhooks for the account we're connected with. |
| 246 | +> a **Response 400 is returned when** : |
| 247 | +> <ul> |
| 248 | +> <li>the `page` query parameter is not valid </li> |
| 249 | +> <li>the `pageSize` query parameter is not valid </li> |
| 250 | +> </ul> |
| 251 | +
|
| 252 | +```python |
| 253 | +def retrieve(self, |
| 254 | + page=None, |
| 255 | + page_size=None) |
| 256 | +``` |
| 257 | + |
| 258 | +#### Parameters |
| 259 | + |
| 260 | +| Parameter | Tags | Description | |
| 261 | +|-----------|------|-------------| |
| 262 | +| page | ``` Optional ``` | TODO: Add a parameter description | |
| 263 | +| pageSize | ``` Optional ``` | TODO: Add a parameter description | |
| 264 | + |
| 265 | + |
| 266 | + |
| 267 | +#### Example Usage |
| 268 | + |
| 269 | +```python |
| 270 | +page = '1' |
| 271 | +page_size = '10' |
| 272 | + |
| 273 | +result = client_controller.retrieve(page, page_size) |
| 274 | + |
| 275 | +``` |
| 276 | + |
| 277 | +#### Errors |
| 278 | + |
| 279 | +| Error Code | Error Description | |
| 280 | +|------------|-------------------| |
| 281 | +| 400 | TODO: Add an error description | |
| 282 | + |
| 283 | + |
| 284 | + |
| 285 | + |
| 286 | +### <a name="update"></a> update |
| 287 | + |
| 288 | +> This will update a webhook and returned the updated Webhook. |
| 289 | +> you can update all the attributes individually or together. |
| 290 | +> PS : the new value will override the previous one. |
| 291 | +> ### Parameters |
| 292 | +> + same parameters rules as create webhook apply |
| 293 | +> a **Response 404 is returned when** : |
| 294 | +> <ul> |
| 295 | +> <li>there is no webhook with this `webhookId` </li> |
| 296 | +> </ul> |
| 297 | +> a **Response 400 is returned when** : |
| 298 | +> <ul> |
| 299 | +> <li>all attributes are null </li> |
| 300 | +> <li>events array is empty </li> |
| 301 | +> <li>content-Type is set in the headers instead of using the `encoding` attribute </li> |
| 302 | +> </ul> |
| 303 | +
|
| 304 | +```python |
| 305 | +def update(self, |
| 306 | + webhook_id, |
| 307 | + content_type, |
| 308 | + body) |
| 309 | +``` |
| 310 | + |
| 311 | +#### Parameters |
| 312 | + |
| 313 | +| Parameter | Tags | Description | |
| 314 | +|-----------|------|-------------| |
| 315 | +| webhookId | ``` Required ``` | TODO: Add a parameter description | |
| 316 | +| contentType | ``` Required ``` | TODO: Add a parameter description | |
| 317 | +| body | ``` Required ``` | TODO: Add a parameter description | |
| 318 | + |
| 319 | + |
| 320 | + |
| 321 | +#### Example Usage |
| 322 | + |
| 323 | +```python |
| 324 | +webhook_id = uuid.uuid4() |
| 325 | +content_type = 'Content-Type' |
| 326 | +body = UpdateRequest() |
| 327 | + |
| 328 | +client_controller.update(webhook_id, content_type, body) |
| 329 | + |
| 330 | +``` |
| 331 | + |
| 332 | +#### Errors |
| 333 | + |
| 334 | +| Error Code | Error Description | |
| 335 | +|------------|-------------------| |
| 336 | +| 404 | TODO: Add an error description | |
| 337 | + |
| 338 | + |
| 339 | + |
| 340 | + |
| 341 | +[Back to List of Controllers](#list_of_controllers) |
| 342 | + |
| 343 | + |
| 344 | + |
0 commit comments