internal Sms(ISmsApiEndpoints smsApiEndpoints, string to, string message) { _smsApiEndpoints = smsApiEndpoints; if (string.IsNullOrWhiteSpace(to)) { throw new BadRequestException("Cannot specify empty 'to'."); } if (string.IsNullOrWhiteSpace(message)) { throw new BadRequestException("Cannot specify empty message."); } if (!to.Trim().StartsWith("+")) { throw new BadRequestException("'to' must be in international format. Phone number should start with a '+'"); } if (to.Length < 7) { throw new BadRequestException("Phone number too short"); } if (to.Length > 17) { throw new BadRequestException("Phone number too long"); } if (to.Substring(1).Any(c => !char.IsDigit(c))) { throw new BadRequestException("Phone numbers should only have digits after '+'"); } _to = to.Trim(); _message = message.Trim(); }
internal SmsApi(ISmsApiEndpoints smsApiEndpoints) { _smsApiEndpoints = smsApiEndpoints; }