|
| 1 | +# Getting started |
| 2 | + |
| 3 | +TODO: Add a description |
| 4 | + |
| 5 | +## How to Build |
| 6 | + |
| 7 | +The generated code uses the Newtonsoft Json.NET NuGet Package. If the automatic NuGet package restore |
| 8 | +is enabled, these dependencies will be installed automatically. Therefore, |
| 9 | +you will need internet access for build. |
| 10 | + |
| 11 | +1. Open the solution (MessageMediaWebhooks.sln) file. |
| 12 | +2. Invoke the build process using `Ctrl+Shift+B` shortcut key or using the `Build` menu as shown below. |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +## How to Use |
| 17 | + |
| 18 | +The build process generates a portable class library, which can be used like a normal class library. The generated library is compatible with Windows Forms, Windows RT, Windows Phone 8, |
| 19 | +Silverlight 5, Xamarin iOS, Xamarin Android and Mono. More information on how to use can be found at the [MSDN Portable Class Libraries documentation](http://msdn.microsoft.com/en-us/library/vstudio/gg597391%28v=vs.100%29.aspx). |
| 20 | + |
| 21 | +The following section explains how to use the MessageMediaWebhooks library in a new console project. |
| 22 | + |
| 23 | +### 1. Starting a new project |
| 24 | + |
| 25 | +For starting a new project, right click on the current solution from the *solution explorer* and choose ``` Add -> New Project ```. |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +Next, choose "Console Application", provide a ``` TestConsoleProject ``` as the project name and click ``` OK ```. |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +### 2. Set as startup project |
| 34 | + |
| 35 | +The new console project is the entry point for the eventual execution. This requires us to set the ``` TestConsoleProject ``` as the start-up project. To do this, right-click on the ``` TestConsoleProject ``` and choose ``` Set as StartUp Project ``` form the context menu. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +### 3. Add reference of the library project |
| 40 | + |
| 41 | +In order to use the MessageMediaWebhooks library in the new project, first we must add a projet reference to the ``` TestConsoleProject ```. First, right click on the ``` References ``` node in the *solution explorer* and click ``` Add Reference... ```. |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +Next, a window will be displayed where we must set the ``` checkbox ``` on ``` MessageMediaWebhooks.Tests ``` and click ``` OK ```. By doing this, we have added a reference of the ```MessageMediaWebhooks.Tests``` project into the new ``` TestConsoleProject ```. |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +### 4. Write sample code |
| 50 | + |
| 51 | +Once the ``` TestConsoleProject ``` is created, a file named ``` Program.cs ``` will be visible in the *solution explorer* with an empty ``` Main ``` method. This is the entry point for the execution of the entire solution. |
| 52 | +Here, you can add code to initialize the client library and acquire the instance of a *Controller* class. Sample code to initialize the client library and using controller methods is given in the subsequent sections. |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +## How to Test |
| 57 | + |
| 58 | +The generated SDK also contain one or more Tests, which are contained in the Tests project. |
| 59 | +In order to invoke these test cases, you will need *NUnit 3.0 Test Adapter Extension for Visual Studio*. |
| 60 | +Once the SDK is complied, the test cases should appear in the Test Explorer window. |
| 61 | +Here, you can click *Run All* to execute these test cases. |
| 62 | + |
| 63 | +## Initialization |
| 64 | + |
| 65 | +### Authentication |
| 66 | +In order to setup authentication and initialization of the API client, you need the following information. |
| 67 | + |
| 68 | +| Parameter | Description | |
| 69 | +|-----------|-------------| |
| 70 | +| basicAuthUserName | The username to use with basic authentication | |
| 71 | +| basicAuthPassword | The password to use with basic authentication | |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | +API client can be initialized as following. |
| 76 | + |
| 77 | +```csharp |
| 78 | +// Configuration parameters and credentials |
| 79 | +string basicAuthUserName = "basicAuthUserName"; // The username to use with basic authentication |
| 80 | +string basicAuthPassword = "basicAuthPassword"; // The password to use with basic authentication |
| 81 | + |
| 82 | +MessageMediaWebhooksClient client = new MessageMediaWebhooksClient(basicAuthUserName, basicAuthPassword); |
| 83 | +``` |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | +# Class Reference |
| 88 | + |
| 89 | +## <a name="list_of_controllers"></a>List of Controllers |
| 90 | + |
| 91 | +* [APIController](#api_controller) |
| 92 | + |
| 93 | +## <a name="api_controller"></a> APIController |
| 94 | + |
| 95 | +### Get singleton instance |
| 96 | + |
| 97 | +The singleton instance of the ``` APIController ``` class can be accessed from the API Client. |
| 98 | + |
| 99 | +```csharp |
| 100 | +IAPIController client = client.Client; |
| 101 | +``` |
| 102 | + |
| 103 | +### <a name="create"></a> Create |
| 104 | + |
| 105 | +> This will create a webhook for the specified `events` |
| 106 | +> ### Parameters |
| 107 | +> **list of supported parameters in `template` according to the message type :** |
| 108 | +> you must escape the json for the template parameter. see example . |
| 109 | +> | Data | parameter name | DR| MO | MO MMS | Comment | |
| 110 | +> |:--|--|--|--|--|--| |
| 111 | +> | **service type** | $type| ``OK`` |`OK`| `OK`| | |
| 112 | +> | **Message ID** | $mtId, $messageId| `OK` |`OK`| `OK`| | |
| 113 | +> | **Delivery report ID** |$drId, $reportId | `OK` || | | |
| 114 | +> | **Reply ID**| $moId, $replyId| |`OK`| `OK`|| |
| 115 | +> | **Account ID** | $accountId| `OK` |`OK`| `OK`|| |
| 116 | +> | **Message Timestamp** | $submittedTimestamp| `OK` |`OK`| `OK`|| |
| 117 | +> | **Provider Timestamp** | $receivedTimestamp| `OK` |`OK`| `OK`|| |
| 118 | +> | **Message status** | $status| `OK` |||| |
| 119 | +> | **Status code** | $statusCode| `OK` |||| |
| 120 | +> | **External metadata** | $metadata.get('key')| `OK` |`OK`| `OK`|| |
| 121 | +> | **Source address**| $sourceAddress| `OK` |`OK`| `OK`|| |
| 122 | +> | **Destination address**| $destinationAddress| |`OK`| `OK`|| |
| 123 | +> | **Message content**| $mtContent, $messageContent| `OK` |`OK`| `OK`|| |
| 124 | +> | **Reply Content**| $moContent, $replyContent| |`OK`| `OK`|| |
| 125 | +> | **Retry Count**| $retryCount| `OK` |`OK`| `OK`|| |
| 126 | +> **list of allowed `events` :** |
| 127 | +> you can combine all the events whatever the message type.(at least one Event set otherwise the webhook won't be created) |
| 128 | +> + **events for SMS** |
| 129 | +> + `RECEIVED_SMS` |
| 130 | +> + `OPT_OUT_SMS` |
| 131 | +> + **events for MMS** |
| 132 | +> + `RECEIVED_MMS` |
| 133 | +> + **events for DR** |
| 134 | +> + `ENROUTE_DR` |
| 135 | +> + `EXPIRED_DR` |
| 136 | +> + `REJECTED_DR` |
| 137 | +> + `FAILED_DR` |
| 138 | +> + `DELIVERED_DR` |
| 139 | +> + `SUBMITTED_DR` |
| 140 | +> a **Response 400 is returned when** : |
| 141 | +> <ul> |
| 142 | +> <li>the `url` is not valid </li> |
| 143 | +> <li>the `events` is null/empty </li> |
| 144 | +> <li>the `encoding` is null </li> |
| 145 | +> <li>the `method` is null </li> |
| 146 | +> <li>the `headers` has a `ContentType` attribute </li> |
| 147 | +> </ul> |
| 148 | + |
| 149 | + |
| 150 | +```csharp |
| 151 | +Task<dynamic> Create(string contentType, Webhooks.Models.CreateRequest body) |
| 152 | +``` |
| 153 | + |
| 154 | +#### Parameters |
| 155 | + |
| 156 | +| Parameter | Tags | Description | |
| 157 | +|-----------|------|-------------| |
| 158 | +| contentType | ``` Required ``` | TODO: Add a parameter description | |
| 159 | +| body | ``` Required ``` | TODO: Add a parameter description | |
| 160 | + |
| 161 | + |
| 162 | +#### Example Usage |
| 163 | + |
| 164 | +```csharp |
| 165 | +string contentType = "Content-Type"; |
| 166 | +var body = new Webhooks.Models.CreateRequest(); |
| 167 | + |
| 168 | +dynamic result = await client.Create(contentType, body); |
| 169 | + |
| 170 | +``` |
| 171 | + |
| 172 | +#### Errors |
| 173 | + |
| 174 | +| Error Code | Error Description | |
| 175 | +|------------|-------------------| |
| 176 | +| 400 | TODO: Add an error description | |
| 177 | + |
| 178 | + |
| 179 | +### <a name="delete_delete_and_update_webhook"></a> DeleteDeleteAndUpdateWebhook |
| 180 | + |
| 181 | +> This will delete the webhook wuth the give id. |
| 182 | +> a **Response 404 is returned when** : |
| 183 | +> <ul> |
| 184 | +> <li>there is no webhook with this `webhookId` </li> |
| 185 | +> </ul> |
| 186 | + |
| 187 | + |
| 188 | +```csharp |
| 189 | +Task DeleteDeleteAndUpdateWebhook(Guid webhookId) |
| 190 | +``` |
| 191 | + |
| 192 | +#### Parameters |
| 193 | + |
| 194 | +| Parameter | Tags | Description | |
| 195 | +|-----------|------|-------------| |
| 196 | +| webhookId | ``` Required ``` | TODO: Add a parameter description | |
| 197 | + |
| 198 | + |
| 199 | +#### Example Usage |
| 200 | + |
| 201 | +```csharp |
| 202 | +Guid webhookId = a7f11bb0-f299-4861-a5ca-9b29d04bc5ad; |
| 203 | + |
| 204 | +await client.DeleteDeleteAndUpdateWebhook(webhookId); |
| 205 | + |
| 206 | +``` |
| 207 | + |
| 208 | +#### Errors |
| 209 | + |
| 210 | +| Error Code | Error Description | |
| 211 | +|------------|-------------------| |
| 212 | +| 404 | TODO: Add an error description | |
| 213 | + |
| 214 | + |
| 215 | +### <a name="retrieve"></a> Retrieve |
| 216 | + |
| 217 | +> This will retrieve all webhooks for the account we're connected with. |
| 218 | +> a **Response 400 is returned when** : |
| 219 | +> <ul> |
| 220 | +> <li>the `page` query parameter is not valid </li> |
| 221 | +> <li>the `pageSize` query parameter is not valid </li> |
| 222 | +> </ul> |
| 223 | + |
| 224 | + |
| 225 | +```csharp |
| 226 | +Task<Webhooks.Models.RetrieveResponse> Retrieve(int? page = null, int? pageSize = null) |
| 227 | +``` |
| 228 | + |
| 229 | +#### Parameters |
| 230 | + |
| 231 | +| Parameter | Tags | Description | |
| 232 | +|-----------|------|-------------| |
| 233 | +| page | ``` Optional ``` | TODO: Add a parameter description | |
| 234 | +| pageSize | ``` Optional ``` | TODO: Add a parameter description | |
| 235 | + |
| 236 | + |
| 237 | +#### Example Usage |
| 238 | + |
| 239 | +```csharp |
| 240 | +int? page = '1'; |
| 241 | +int? pageSize = '10'; |
| 242 | + |
| 243 | +Webhooks.Models.RetrieveResponse result = await client.Retrieve(page, pageSize); |
| 244 | + |
| 245 | +``` |
| 246 | + |
| 247 | +#### Errors |
| 248 | + |
| 249 | +| Error Code | Error Description | |
| 250 | +|------------|-------------------| |
| 251 | +| 400 | TODO: Add an error description | |
| 252 | + |
| 253 | + |
| 254 | +### <a name="update"></a> Update |
| 255 | + |
| 256 | +> This will update a webhook and returned the updated Webhook. |
| 257 | +> you can update all the attributes individually or together. |
| 258 | +> PS : the new value will override the previous one. |
| 259 | +> ### Parameters |
| 260 | +> + same parameters rules as create webhook apply |
| 261 | +> a **Response 404 is returned when** : |
| 262 | +> <ul> |
| 263 | +> <li>there is no webhook with this `webhookId` </li> |
| 264 | +> </ul> |
| 265 | +> a **Response 400 is returned when** : |
| 266 | +> <ul> |
| 267 | +> <li>all attributes are null </li> |
| 268 | +> <li>events array is empty </li> |
| 269 | +> <li>content-Type is set in the headers instead of using the `encoding` attribute </li> |
| 270 | +> </ul> |
| 271 | + |
| 272 | + |
| 273 | +```csharp |
| 274 | +Task Update(Guid webhookId, string contentType, Webhooks.Models.UpdateRequest body) |
| 275 | +``` |
| 276 | + |
| 277 | +#### Parameters |
| 278 | + |
| 279 | +| Parameter | Tags | Description | |
| 280 | +|-----------|------|-------------| |
| 281 | +| webhookId | ``` Required ``` | TODO: Add a parameter description | |
| 282 | +| contentType | ``` Required ``` | TODO: Add a parameter description | |
| 283 | +| body | ``` Required ``` | TODO: Add a parameter description | |
| 284 | + |
| 285 | + |
| 286 | +#### Example Usage |
| 287 | + |
| 288 | +```csharp |
| 289 | +Guid webhookId = Guid.NewGuid(); |
| 290 | +string contentType = "Content-Type"; |
| 291 | +var body = new Webhooks.Models.UpdateRequest(); |
| 292 | + |
| 293 | +await client.Update(webhookId, contentType, body); |
| 294 | + |
| 295 | +``` |
| 296 | + |
| 297 | +#### Errors |
| 298 | + |
| 299 | +| Error Code | Error Description | |
| 300 | +|------------|-------------------| |
| 301 | +| 404 | TODO: Add an error description | |
| 302 | + |
| 303 | + |
| 304 | +[Back to List of Controllers](#list_of_controllers) |
0 commit comments