Пример #1
0
        private static FetchPhoneNumberOptions BuildTwilioRequestOptions(string countryCode, Twilio.Types.PhoneNumber twilioPhoneNumber)
        {
            var options = new FetchPhoneNumberOptions(twilioPhoneNumber)
            {
                CountryCode = countryCode
            };

            options.Type.Add("carrier");

            return(options);
        }
Пример #2
0
        public async Task LookupNumber_CallsTwilioWrapper_WithCorrectCountryCode()
        {
            FetchPhoneNumberOptions fetchOptions = null;

            var options = new Mock <IOptions <TwilioSettings> >();

            options.Setup(x => x.Value).Returns(new TwilioSettings {
                Sid = "123", Token = "ABC", PhoneNo = "1234567890"
            });

            var twilioWrapper = new Mock <ITwilioWrapper>();

            twilioWrapper.Setup(x => x.FetchPhoneNumberResource(It.IsAny <FetchPhoneNumberOptions>(), It.IsAny <ITwilioRestClient>()))
            .Callback <FetchPhoneNumberOptions, ITwilioRestClient>((x, y) => fetchOptions = x);

            var sut = new TwilioPhoneNumberLookupService(options.Object, twilioWrapper.Object);

            await sut.LookupNumber("123456789", "us");

            fetchOptions.CountryCode.ShouldBe("us");
        }
Пример #3
0
        public static async Task <PhoneNumberResource> LookupPhoneNumber(ITwilioRestClient client, string number, CountryCode?countryCode, bool includeCallerName, bool includeCarrier, List <string> addOns, Dictionary <string, object> addOnsData)
        {
            var phoneNumber = new Twilio.Types.PhoneNumber(number);
            var type        = new List <string>();

            if (includeCallerName)
            {
                type.Add("caller_name");
            }
            if (includeCarrier)
            {
                type.Add("carrier");
            }
            var options = new FetchPhoneNumberOptions(phoneNumber)
            {
                CountryCode = countryCode != null ? $"{countryCode:G}" : null,
                Type        = type,
                AddOns      = addOns,
                AddOnsData  = addOnsData
            };

            return(await PhoneNumberResource.FetchAsync(options, client));
        }
Пример #4
0
 public async Task <PhoneNumberResource> FetchPhoneNumberResource(FetchPhoneNumberOptions fetchOptions, ITwilioRestClient twilioClient)
 {
     return(await PhoneNumberResource.FetchAsync(fetchOptions, twilioClient));
 }