Ejemplo n.º 1
0
        public static async Task <ResourceSet <LocalResource> > GetAvailableLocalPhoneNumberAsync(ITwilioRestClient client, CountryCode countryCode, string accountSid = null, int?areaCode = null, bool?smsEnabled = null, bool?mmsEnabled = null, bool?faxEnabled = null, bool?voiceEnabled = null, bool?beta = null, string containsPattern = null, string lata = null, string latLong = null, string nearNumber = null, int?distance = null, string locality = null, string postalCode = null, string rateCenter = null, string region = null, bool?excludeAllAddressRequired = null, bool?excludeForeignAddressRequired = null, bool?excludeLocalAddressRequired = null, long?limit = null)
        {
            var nearPhoneNumber = nearNumber != null ? new PhoneNumber(nearNumber) : null;
            var options         = new ReadLocalOptions($"{countryCode:G}")
            {
                PathAccountSid                = accountSid,
                AreaCode                      = areaCode,
                SmsEnabled                    = smsEnabled,
                MmsEnabled                    = mmsEnabled,
                FaxEnabled                    = faxEnabled,
                VoiceEnabled                  = voiceEnabled,
                Beta                          = beta,
                Contains                      = containsPattern,
                InLata                        = lata,
                NearLatLong                   = latLong,
                NearNumber                    = nearPhoneNumber,
                Distance                      = distance,
                InLocality                    = locality,
                InPostalCode                  = postalCode,
                InRateCenter                  = rateCenter,
                InRegion                      = region,
                ExcludeAllAddressRequired     = excludeAllAddressRequired,
                ExcludeForeignAddressRequired = excludeForeignAddressRequired,
                ExcludeLocalAddressRequired   = excludeLocalAddressRequired,
                Limit                         = limit,
                PageSize                      = null
            };

            return(await LocalResource.ReadAsync(options, client));
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <LocalResource> > SearchPhoneNumbersAsync(string areaCode = "415")
        {
            var localNumbers = await LocalResource.ReadAsync(
                pathCountryCode : "US", areaCode : int.Parse(areaCode), client : _client);

            return(localNumbers.ToList());
        }
Ejemplo n.º 3
0
        public virtual async Task <ResourceSet <LocalResource> > GetLocalPhoneNumber(string areaCode = null)
        {
            var code = areaCode.ToNullableInt();
            ResourceSet <LocalResource> result;

            try
            {
                result = await LocalResource.ReadAsync(pathCountryCode : "US", areaCode : code);
            }
            catch (ApiException)
            {
                result = null;
            }
            return(result);
        }