private static void GetInboxMessagesExample(EsendexCredentials credentials, MessageBodyService messageBodyService) { var inboxService = new InboxService(credentials); try { var collection = inboxService.GetMessages(_accountReference, PageIndex, PageSize); foreach (var item in collection.Messages) { if (messageBodyService != null) { messageBodyService.LoadBodyText(item.Body); Console.WriteLine("\tMessage Id:{0}\tSummary:{1}\n\tBody:{2}\n", item.Id, item.Summary, item.Body.BodyText); } else { Console.WriteLine("\tMessage Id:{0}\tSummary:{1}", item.Id, item.Summary); } } } catch (WebException ex) { Console.Write(ex.Message); } }
public void TestInitialize() { mockSerialiser = new Mock <ISerialiser>(); mockRestClient = new Mock <IRestClient>(); service = new MessageBodyService(mockRestClient.Object, mockSerialiser.Object); }
static void Main(string[] args) { var helpRequested = false; var sendMessage = false; var optionSet = new OptionSet { { "u|user="******"Username to use", user => _username = user }, { "p|pass="******"Password for Username", pass => _password = pass }, { "a|account=", "Account Reference to use", reference => _accountReference = reference }, { "s|send=", "Send a message to the provided number", sendTo => { sendMessage = true; _sendTo = sendTo; } }, { "b|bodies+", "Retrieve message bodies", v => _getBodies = true }, { "h|help", "Help about the command line interface", key => { helpRequested = key != null; } } }; try { optionSet.Parse(args); if (!helpRequested && (string.IsNullOrEmpty(_username) || string.IsNullOrEmpty(_password) || string.IsNullOrEmpty(_accountReference))) { throw new ApplicationException("Samples require username, password and account reference be given"); } } catch (Exception e) { Console.WriteLine(e.Message); helpRequested = true; } if (helpRequested) { ShowUsage(optionSet); return; } EsendexCredentials credentials; try { credentials = new EsendexCredentials(_username, _password); var sessionService = new SessionService(credentials); credentials.SessionId = sessionService.CreateSession(); } catch (WebException ex) { Console.Write(ex.Message); return; } if (sendMessage) { Console.WriteLine("Send Message Example\r\n"); SendMessageExample(credentials); } MessageBodyService messageBodyService = null; if (_getBodies) { messageBodyService = new MessageBodyService(credentials); } Console.WriteLine(); Console.WriteLine("Sent Messages Example\r\n"); GetSentMessagesExample(credentials, messageBodyService); Console.WriteLine(); Console.WriteLine("Inbox Messages Example\r\n"); GetInboxMessagesExample(credentials, messageBodyService); Console.WriteLine(); Console.WriteLine("Contacts Example\r\n"); GetContactsExample(credentials); Console.WriteLine(); Console.WriteLine("Groups Example\r\n"); GetGroupsExample(credentials); Console.WriteLine(); Console.WriteLine("Contacts in Group Example\r\n"); GetContactsByGroupExample(credentials); AddContactToGroup(credentials); Console.WriteLine(); Console.WriteLine("Press enter to continue ... "); Console.ReadLine(); }