Hi all!
We a partner that tested this script for importing contacts and send message, and it´s working good so far for him.
Script:
private static string TreatPhone(string phone) =>
NeedsDigit(phone) ? EnsureDigit(phone) : RemoveDigit(phone);
private static string EnsureDigit(string phone) =>
phone.Length == 13 ? phone.Insert(5, DIGIT) : phone;
private static string RemoveDigit(string phone) =>
phone.Length == 14 ? phone.Remove(5, 1) : phone;
private static bool NeedsDigit(string phone) =>
string.Compare(phone.Substring(3, 2), LAST_DDD_WITH_REQUIRED_DIGIT) <= 0;
private const string DIGIT = "9";
private const string LAST_DDD_WITH_REQUIRED_DIGIT = "29";
private static readonly string[] DDD = new[]
{
"11", "12", "13", "14", "15", "16", "17", "18", "19",
"21", "22", "24", "27", "28",
"31", "32", "33", "34", "35", "37", "38",
"41", "42", "43", "44", "45", "46", "47", "48", "49",
"51", "53", "54", "55",
"61", "62", "63", "64", "65", "66", "67", "68", "69",
"71", "73", "74", "75", "77", "79",
"81", "82", "83", "84", "85", "86", "87", "88", "89",
"91", "92", "93", "94", "95", "96", "97", "98", "99"
};
Could you implement it for correcting contacts while importing, or when using api call with external token and smschat api calls.
I think we will solve many problem with message delivery, because this script is considering Brazil cities phone configuration.
Thank you.
Clayton Aires