Skip to content

Commit c833802

Browse files
author
David Edgar
committed
Fix syntax errors in README sample code
1 parent 45f7670 commit c833802

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ It's easy to get started. Simply enter the API Key and secret you obtained from
7575
Destination numbers (`destination_number`) should be in the [E.164](http://en.wikipedia.org/wiki/E.164) format. For example, `+61491570156`.
7676
```csharp
7777
using System;
78+
using System.Linq;
7879
using MessageMedia.Messages;
7980
using MessageMedia.Messages.Controllers;
8081
using MessageMedia.Messages.Models;
8182

83+
8284
namespace TestCSharpSDK
8385
{
8486
class Program
@@ -89,25 +91,24 @@ namespace TestCSharpSDK
8991
String basicAuthUserName = "YOUR_API_KEY";
9092
String basicAuthPassword = "YOUR_API_SECRET";
9193
bool useHmacAuthentication = false; //Change this to true if you are using HMAC keys
92-
94+
9395
// Instantiate the client
9496
MessageMediaMessagesClient client = new MessageMediaMessagesClient(basicAuthUserName, basicAuthPassword, useHmacAuthentication);
9597
IMessagesController messages = client.Messages;
9698

97-
// Perform API call
98-
string bodyValue = @"{
99-
""messages"":[
100-
{
101-
""content"":""Greetings from MessageMedia!"",
102-
""destination_number"":""YOUR_MOBILE_NUMBER""
103-
}
104-
]
105-
}";
106-
107-
var body = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageMedia.Messages.Models.SendMessagesRequest>(bodyValue);
108-
109-
MessageMedia.Messages.Models.SendMessagesResponse result = messages.CreateSendMessages(body);
110-
Console.WriteLine(result.Messages);
99+
var request = new SendMessagesRequest() {
100+
Messages = new []{
101+
new Message() {
102+
Content = "Greetings from MessageMedia!",
103+
DestinationNumber = "YOUR_MOBILE_NUMBER"
104+
}
105+
}
106+
};
107+
108+
SendMessagesResponse result = messages.CreateSendMessages(request);
109+
Message message = result.Messages.First();
110+
111+
Console.WriteLine("Status: {0}, Message Id: {1}", message.Status, message.MessageId);
111112
Console.ReadKey();
112113
}
113114
}
@@ -118,6 +119,7 @@ namespace TestCSharpSDK
118119
Destination numbers (`destination_number`) should be in the [E.164](http://en.wikipedia.org/wiki/E.164) format. For example, `+61491570156`.
119120
```csharp
120121
using System;
122+
using System.Linq;
121123
using MessageMedia.Messages;
122124
using MessageMedia.Messages.Controllers;
123125
using MessageMedia.Messages.Models;
@@ -153,8 +155,8 @@ namespace TestCSharpSDK
153155
}
154156
}
155157
};
156-
157-
Message message = result.Messages.First();
158+
SendMessagesResponse result = messages.CreateSendMessages(request);
159+
Message message = result.Messages.First();
158160

159161
Console.WriteLine("Status: {0}, Message Id: {1}", message.Status, message.MessageId);
160162
Console.ReadKey();
@@ -181,7 +183,7 @@ namespace TestCSharpSDK
181183
String basicAuthUserName = "YOUR_API_KEY";
182184
String basicAuthPassword = "YOUR_API_SECRET";
183185
bool useHmacAuthentication = false; //Change this to true if you are using HMAC keys
184-
186+
185187
// Instantiate the client
186188
MessageMediaMessagesClient client = new MessageMediaMessagesClient(basicAuthUserName, basicAuthPassword, useHmacAuthentication);
187189
IMessagesController messages = client.Messages;
@@ -214,7 +216,7 @@ namespace TestCSharpSDK
214216
String basicAuthUserName = "YOUR_API_KEY";
215217
String basicAuthPassword = "YOUR_API_SECRET";
216218
bool useHmacAuthentication = false; //Change this to true if you are using HMAC keys
217-
219+
218220
// Instantiate the client
219221
MessageMediaMessagesClient client = new MessageMediaMessagesClient(basicAuthUserName, basicAuthPassword, useHmacAuthentication);
220222
IRepliesController replies = client.Replies;
@@ -246,7 +248,7 @@ namespace TestCSharpSDK
246248
String basicAuthUserName = "YOUR_API_KEY";
247249
String basicAuthPassword = "YOUR_API_SECRET";
248250
bool useHmacAuthentication = false; //Change this to true if you are using HMAC keys
249-
251+
250252
// Instantiate the client
251253
MessageMediaMessagesClient client = new MessageMediaMessagesClient(basicAuthUserName, basicAuthPassword, useHmacAuthentication);
252254
IDeliveryReportsController deliveryReports = client.DeliveryReports;
@@ -267,4 +269,4 @@ Check out the [full API documentation](https://developers.messagemedia.com/code/
267269
Please contact developer support at [email protected] or check out the developer portal at [developers.messagemedia.com](https://developers.messagemedia.com/)
268270

269271
## :page_with_curl: License
270-
Apache License. See the [LICENSE](LICENSE) file.
272+
Apache License. See the [LICENSE](LICENSE) file.

0 commit comments

Comments
 (0)