/// <summary> /// Creates the user. /// </summary> /// <param name="user">User model to create</param> public void CreateUser(CreateUserRequest user) { var requestUrl = string.Format("{0}{1}&Action=CreateUser&ChildUsername={2}&ChildPassword={3}&AccessLevel={4}&FirstName={5}" + "&LastName={6}&Email={7}&Credits={8}&CreditReminder={9}&Alert={10}&Telephone={11}", ApiUrl, _token, user.ChildUsername, user.ChildPassword, user.AccessLevel, user.FirstName, user.LastName, user.Email, user.Credits, user.CreditReminder, user.Alert, user.Telephone); var result = _httpClient.GetResponse(requestUrl); if (result.AsIntSafe() != 1) { throw new FastSmsException(result); } }
private static void CompileCommand(string[] args) { var client = new FastSmsClient("6Rx6-stiU-a8sY-vt9i"); var commandArguments = args; if (!commandArguments.Any()) return; var command = commandArguments[0]; switch (command) { case "CheckCredits": Console.WriteLine(client.CheckCredits()); break; case "CheckMessageStatus": if (commandArguments.Length != 2) Console.WriteLine(ArgumentError); else Console.WriteLine(client.CheckMessageStatus(commandArguments[1])); break; case "UpdateCredits": int i; if (commandArguments.Length != 3 || !int.TryParse(commandArguments[2], out i)) Console.WriteLine(ArgumentError); else { client.UpdateCredits(commandArguments[1], i); Console.WriteLine(Success); } break; case "DeleteAllContacts": if (commandArguments.Length != 1) Console.WriteLine(ArgumentError); else { client.DeleteAllContacts(); Console.WriteLine(Success); } break; case "DeleteAllGroups": if (commandArguments.Length != 1) Console.WriteLine(ArgumentError); else { client.DeleteAllGroups(); Console.WriteLine(Success); } break; case "EmptyGroup": if (commandArguments.Length != 2) Console.WriteLine(ArgumentError); else { client.EmptyGroup(commandArguments[1]); Console.WriteLine(Success); } break; case "DeleteGroup": if (commandArguments.Length != 2) Console.WriteLine(ArgumentError); else { client.DeleteGroup(commandArguments[1]); Console.WriteLine(Success); } break; case "CreateUser": if (commandArguments.Length != 3) { Console.WriteLine(ArgumentError); } else { var user = new CreateUserRequest(commandArguments[1], commandArguments[2]) { LastName = "User Last name", AccessLevel = "Normal", ChildPassword = "******", Email = @"*****@*****.**", Credits = 100 }; client.CreateUser(user); Console.WriteLine(Success); } break; case "SendMessageToUser": if (commandArguments.Length != 3) { Console.WriteLine(ArgumentError); } else { var message = new SendMessageToUserRequest() { Body = commandArguments[1], DestinationAddress = commandArguments[2] }; client.SendMessage(message); Console.WriteLine(Success); } break; case "SendMessageToGroup": if (commandArguments.Length != 3) { Console.WriteLine(ArgumentError); } else { var message = new MessageToGroupRequest() { Body = commandArguments[1], GroupName = commandArguments[2] }; client.SendMessage(message); Console.WriteLine(Success); } break; case "SendMessageToList": if (commandArguments.Length != 3) { Console.WriteLine(ArgumentError); } else { var message = new SendMessageToListRequest() { Body = commandArguments[1], ListName = commandArguments[2] }; client.SendMessage(message); Console.WriteLine(Success); } break; case "GetReports": if (commandArguments.Length != 4) { Console.WriteLine(ArgumentError); } else { var reportType = ReportType.Messages; switch (commandArguments[1]) { case "InboundMessages": reportType = ReportType.InboundMessages; break; case "Messages": reportType = ReportType.Messages; break; case "Outbox": reportType = ReportType.Outbox; break; case "Usage": reportType = ReportType.Usage; break; } var reports = client.GetReports(reportType, commandArguments[2], commandArguments[3]); foreach (var report in reports) { Console.WriteLine(ReportToString(report)); } } break; case "Help": Help(); break; default: break; } }
public void TestInitialize() { Client = new FastSmsClient(); UserModel = new CreateUserRequest { FirstName = "Name", LastName = "LastName", Email = "email", AccessLevel = "Normal", ChildUsername = "******", ChildPassword = "******", Credits = 22 }; }