Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a0132fe

Browse files
Updated files
- Fixed APIMATIC version issue - Added README - Added code examples - Updated tests
1 parent bc9eaae commit a0132fe

File tree

9 files changed

+595
-416
lines changed

9 files changed

+595
-416
lines changed

‎DOCUMENTATION.md‎

Lines changed: 335 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,335 @@
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+
![Building SDK using Visual Studio](https://apidocs.io/illustration/cs?step=buildSDK&workspaceFolder=MessageMediaWebhooks-CSharp&workspaceName=MessageMediaWebhooks&projectName=MessageMediaWebhooks.Tests)
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+
![Add a new project in the existing solution using Visual Studio](https://apidocs.io/illustration/cs?step=addProject&workspaceFolder=MessageMediaWebhooks-CSharp&workspaceName=MessageMediaWebhooks&projectName=MessageMediaWebhooks.Tests)
28+
29+
Next, choose "Console Application", provide a ``` TestConsoleProject ``` as the project name and click ``` OK ```.
30+
31+
![Create a new console project using Visual Studio](https://apidocs.io/illustration/cs?step=createProject&workspaceFolder=MessageMediaWebhooks-CSharp&workspaceName=MessageMediaWebhooks&projectName=MessageMediaWebhooks.Tests)
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+
![Set the new cosole project as the start up project](https://apidocs.io/illustration/cs?step=setStartup&workspaceFolder=MessageMediaWebhooks-CSharp&workspaceName=MessageMediaWebhooks&projectName=MessageMediaWebhooks.Tests)
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+
![Open references of the TestConsoleProject](https://apidocs.io/illustration/cs?step=addReference&workspaceFolder=MessageMediaWebhooks-CSharp&workspaceName=MessageMediaWebhooks&projectName=MessageMediaWebhooks.Tests)
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+
![Add a reference to the TestConsoleProject](https://apidocs.io/illustration/cs?step=createReference&workspaceFolder=MessageMediaWebhooks-CSharp&workspaceName=MessageMediaWebhooks&projectName=MessageMediaWebhooks.Tests)
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+
![Add a reference to the TestConsoleProject](https://apidocs.io/illustration/cs?step=addCode&workspaceFolder=MessageMediaWebhooks-CSharp&workspaceName=MessageMediaWebhooks&projectName=MessageMediaWebhooks.Tests)
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+
* [WebhooksController](#webhooks_controller)
92+
93+
## <a name="webhooks_controller"></a>![Class: ](https://apidocs.io/img/class.png "MessageMedia.Webhooks.Controllers.WebhooksController") WebhooksController
94+
95+
### Get singleton instance
96+
97+
The singleton instance of the ``` WebhooksController ``` class can be accessed from the API Client.
98+
99+
```csharp
100+
IWebhooksController webhooks = client.Webhooks;
101+
```
102+
103+
### <a name="create_webhook"></a>![Method: ](https://apidocs.io/img/method.png "MessageMedia.Webhooks.Controllers.WebhooksController.CreateWebhook") CreateWebhook
104+
105+
> Create a webhook for one or more of the specified events.
106+
> A webhook would typically have the following structure:
107+
> ```
108+
> {
109+
> "url": "http://webhook.com",
110+
> "method": "POST",
111+
> "encoding": "JSON",
112+
> "headers": {
113+
> "Account": "DeveloperPortal7000"
114+
> },
115+
> "events": [
116+
> "RECEIVED_SMS"
117+
> ],
118+
> "template": "{\"id\":\"$mtId\",\"status\":\"$statusCode\"}"
119+
> }
120+
> ```
121+
> A valid webhook must consist of the following properties:
122+
> - ```url``` The configured URL which will trigger the webhook when a selected event occurs.
123+
> - ```method``` The methods to map CRUD (create, retrieve, update, delete) operations to HTTP requests.
124+
> - ```encoding``` The format in which the payload will be returned. You can choose from ```JSON```, ```FORM_ENCODED``` or ```XML```. This will automatically add the Content-Type header for you so you don't have to add it again in the `headers` property.
125+
> - ```headers``` HTTP header fields which provide required information about the request or response, or about the object sent in the message body. This should not include the `Content-Type` header.
126+
> - ```events``` Event or events that will trigger the webhook. Atleast one event should be present.
127+
> - ```template``` The structure of the payload that will be returned.
128+
> #### Types of Events
129+
> You can select all of the events (listed below) or combine them in whatever way you like but atleast one event must be used. Otherwise, the webhook won't be created.
130+
> A webhook will be triggered when any one or more of the events occur:
131+
> + **SMS**
132+
> + `RECEIVED_SMS` Receive an SMS
133+
> + `OPT_OUT_SMS` Opt-out occured
134+
> + **MMS**
135+
> + `RECEIVED_MMS` Receive an MMS
136+
> + **DR (Delivery Reports)**
137+
> + `ENROUTE_DR` Message is enroute
138+
> + `EXPIRED_DR` Message has expired
139+
> + `REJECTED_DR` Message is rejected
140+
> + `FAILED_DR` Message has failed
141+
> + `DELIVERED_DR` Message is delivered
142+
> + `SUBMITTED_DR` Message is submitted
143+
> #### Template Parameters
144+
> You can choose what to include in the data that will be sent as the payload via the Webhook.
145+
> Keep in my mind, you must escape the JSON in the template value (see example above).
146+
> The table illustrates a list of all the parameters that can be included in the template and which event types it can be applied to.
147+
> | Data | Parameter Name | Example | Event Type |
148+
> |:--|--|--|--|--|
149+
> | **Service Type** | $type| `SMS` | `DR` `MO` `MO MMS` |
150+
> | **Message ID** | $mtId, $messageId| `877c19ef-fa2e-4cec-827a-e1df9b5509f7` | `DR` `MO` `MO MMS`|
151+
> | **Delivery Report ID** |$drId, $reportId| `01e1fa0a-6e27-4945-9cdb-18644b4de043` | `DR` |
152+
> | **Reply ID**| $moId, $replyId| `a175e797-2b54-468b-9850-41a3eab32f74` | `MO` `MO MMS` |
153+
> | **Account ID** | $accountId| `DeveloperPortal7000` | `DR` `MO` `MO MMS` |
154+
> | **Message Timestamp** | $submittedTimestamp| `2016年12月07日T08:43:00.850Z` | `DR` `MO` `MO MMS` |
155+
> | **Provider Timestamp** | $receivedTimestamp| `2016年12月07日T08:44:00.850Z` | `DR` `MO` `MO MMS` |
156+
> | **Message Status** | $status| `enroute` | `DR` |
157+
> | **Status Code** | $statusCode| `200` | `DR` |
158+
> | **External Metadata** | $metadata.get('key')| `name` | `DR` `MO` `MO MMS` |
159+
> | **Source Address**| $sourceAddress| `+61491570156` | `DR` `MO` `MO MMS` |
160+
> | **Destination Address**| $destinationAddress| `+61491593156` | `MO` `MO MMS` |
161+
> | **Message Content**| $mtContent, $messageContent| `Hi Derp` | `DR` `MO` `MO MMS` |
162+
> | **Reply Content**| $moContent, $replyContent| `Hello Derpina` | `MO` `MO MMS` |
163+
> | **Retry Count**| $retryCount| `1` | `DR` `MO` `MO MMS` |
164+
> *Note: A 400 response will be returned if the `url` is invalid, the `events`, `encoding` or `method` is null or the `headers` has a Content-Type attribute.*
165+
166+
167+
```csharp
168+
Task<dynamic> CreateWebhook(Webhooks.Models.CreateWebhookRequest body)
169+
```
170+
171+
#### Parameters
172+
173+
| Parameter | Tags | Description |
174+
|-----------|------|-------------|
175+
| body | ``` Required ``` | TODO: Add a parameter description |
176+
177+
178+
#### Example Usage
179+
180+
```csharp
181+
var body = new Webhooks.Models.CreateWebhookRequest();
182+
183+
dynamic result = await webhooks.CreateWebhook(body);
184+
185+
```
186+
187+
#### Errors
188+
189+
| Error Code | Error Description |
190+
|------------|-------------------|
191+
| 400 | Unexpected error in API call. See HTTP response body for details. |
192+
| 409 | Unexpected error in API call. See HTTP response body for details. |
193+
194+
195+
### <a name="retrieve_webhook"></a>![Method: ](https://apidocs.io/img/method.png "MessageMedia.Webhooks.Controllers.WebhooksController.RetrieveWebhook") RetrieveWebhook
196+
197+
> Retrieve all the webhooks created for the connected account.
198+
> A successful request to the retrieve webhook endpoint will return a response body as follows:
199+
> ```
200+
> {
201+
> "page": 0,
202+
> "pageSize": 100,
203+
> "pageData": [
204+
> {
205+
> "url": "https://webhook.com",
206+
> "method": "POST",
207+
> "id": "8805c9d8-bef7-41c7-906a-69ede93aa024",
208+
> "encoding": "JSON",
209+
> "events": [
210+
> "RECEIVED_SMS"
211+
> ],
212+
> "headers": {},
213+
> "template": "{\"id\":\"$mtId\", \"status\":\"$statusCode\"}"
214+
> }
215+
> ]
216+
> }
217+
> ```
218+
> *Note: Response 400 is returned when the `page` query parameter is not valid or the `pageSize` query parameter is not valid.*
219+
220+
221+
```csharp
222+
Task<dynamic> RetrieveWebhook(int? page = null, int? pageSize = null)
223+
```
224+
225+
#### Parameters
226+
227+
| Parameter | Tags | Description |
228+
|-----------|------|-------------|
229+
| page | ``` Optional ``` | TODO: Add a parameter description |
230+
| pageSize | ``` Optional ``` | TODO: Add a parameter description |
231+
232+
233+
#### Example Usage
234+
235+
```csharp
236+
int? page = 0;
237+
int? pageSize = 0;
238+
239+
dynamic result = await webhooks.RetrieveWebhook(page, pageSize);
240+
241+
```
242+
243+
#### Errors
244+
245+
| Error Code | Error Description |
246+
|------------|-------------------|
247+
| 400 | Unexpected error in API call. See HTTP response body for details. |
248+
249+
250+
### <a name="delete_webhook"></a>![Method: ](https://apidocs.io/img/method.png "MessageMedia.Webhooks.Controllers.WebhooksController.DeleteWebhook") DeleteWebhook
251+
252+
> Delete a webhook that was previously created for the connected account.
253+
> A webhook can be cancelled by appending the UUID of the webhook to the endpoint and submitting a DELETE request to the /webhooks/messages endpoint.
254+
> *Note: Only pre-created webhooks can be deleted. If an invalid or non existent webhook ID parameter is specified in the request, then a HTTP 404 Not Found response will be returned.*
255+
256+
257+
```csharp
258+
Task DeleteWebhook(Guid webhookId)
259+
```
260+
261+
#### Parameters
262+
263+
| Parameter | Tags | Description |
264+
|-----------|------|-------------|
265+
| webhookId | ``` Required ``` | TODO: Add a parameter description |
266+
267+
268+
#### Example Usage
269+
270+
```csharp
271+
Guid webhookId = a7f11bb0-f299-4861-a5ca-9b29d04bc5ad;
272+
273+
await webhooks.DeleteWebhook(webhookId);
274+
275+
```
276+
277+
#### Errors
278+
279+
| Error Code | Error Description |
280+
|------------|-------------------|
281+
| 404 | TODO: Add an error description |
282+
283+
284+
### <a name="update_webhook"></a>![Method: ](https://apidocs.io/img/method.png "MessageMedia.Webhooks.Controllers.WebhooksController.UpdateWebhook") UpdateWebhook
285+
286+
> Update a webhook. You can update individual attributes or all of them by submitting a PATCH request to the /webhooks/messages endpoint (the same endpoint used above to delete a webhook)
287+
> A successful request to the retrieve webhook endpoint will return a response body as follows:
288+
> ```
289+
> {
290+
> "url": "https://webhook.com",
291+
> "method": "POST",
292+
> "id": "04442623-0961-464e-9cbc-ec50804e0413",
293+
> "encoding": "JSON",
294+
> "events": [
295+
> "RECEIVED_SMS"
296+
> ],
297+
> "headers": {},
298+
> "template": "{\"id\":\"$mtId\", \"status\":\"$statusCode\"}"
299+
> }
300+
> ```
301+
> *Note: Only pre-created webhooks can be deleted. If an invalid or non existent webhook ID parameter is specified in the request, then a HTTP 404 Not Found response will be returned.*
302+
303+
304+
```csharp
305+
Task<dynamic> UpdateWebhook(Guid webhookId, Webhooks.Models.UpdateWebhookRequest body)
306+
```
307+
308+
#### Parameters
309+
310+
| Parameter | Tags | Description |
311+
|-----------|------|-------------|
312+
| webhookId | ``` Required ``` | TODO: Add a parameter description |
313+
| body | ``` Required ``` | TODO: Add a parameter description |
314+
315+
316+
#### Example Usage
317+
318+
```csharp
319+
Guid webhookId = a7f11bb0-f299-4861-a5ca-9b29d04bc5ad;
320+
string bodyValue = " { \"url\": \"https://myurl.com\", \"method\": \"POST\", \"encoding\": \"FORM_ENCODED\", \"events\": [ \"ENROUTE_DR\" ], \"template\": \"{\\\"id\\\":\\\"$mtId\\\", \\\"status\\\":\\\"$statusCode\\\"}\" }";
321+
var body = Newtonsoft.Json.JsonConvert.DeserializeObject<Webhooks.Models.UpdateWebhookRequest>(bodyValue);
322+
323+
dynamic result = await webhooks.UpdateWebhook(webhookId, body);
324+
325+
```
326+
327+
#### Errors
328+
329+
| Error Code | Error Description |
330+
|------------|-------------------|
331+
| 400 | Unexpected error in API call. See HTTP response body for details. |
332+
| 404 | TODO: Add an error description |
333+
334+
335+
[Back to List of Controllers](#list_of_controllers)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /