Exemple #1
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            // Object Container: Use objectContainer.Get<T>() to retrieve objects from the scope
            var objectContainer = context.GetFromContext <IObjectContainer>(TwilioApiScope.ParentContainerPropertyTag);

            // Inputs
            var countrycode  = CountryCode;
            var accountsid   = AccountSid.Get(context);
            var areacode     = AreaCode.Get(context);
            var smsenabled   = SmsEnabled.Get(context);
            var mmsenabled   = MmsEnabled.Get(context);
            var voiceenabled = VoiceEnabled.Get(context);
            var faxenabled   = FaxEnabled.Get(context);
            var contains     = Contains.Get(context);
            var beta         = Beta.Get(context);
            var nearnumber   = NearNumber.Get(context);
            var nearlatlong  = NearLatLong.Get(context);
            var distance     = Distance.Get(context);
            var inpostalcode = InPostalCode.Get(context);
            var inregion     = InRegion.Get(context);
            var inratecenter = InRateCenter.Get(context);
            var inlata       = InLata.Get(context);
            var inlocality   = InLocality.Get(context);
            var excludealladdressrequired     = ExcludeAllAddressRequired.Get(context);
            var excludelocaladdressrequired   = ExcludeLocalAddressRequired.Get(context);
            var excludeforeignaddressrequired = ExcludeForeignAddressRequired.Get(context);
            var limit = Limit.Get(context);

            var numbers = await AvailableMobilePhoneNumbersWrappers.GetAvailableMobilePhoneNumberAsync(
                objectContainer.Get <ITwilioRestClient>(), countrycode, accountsid, areacode, smsenabled, mmsenabled,
                faxenabled, voiceenabled, beta, contains, inlata, nearlatlong, nearnumber, distance, inlocality,
                inpostalcode, inratecenter, inregion, excludealladdressrequired, excludeforeignaddressrequired,
                excludelocaladdressrequired, limit);

            // Outputs
            return((ctx) => {
                PhoneNumbers.Set(ctx, numbers);
            });
        }
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public override List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (AreaCode != null)
            {
                p.Add(new KeyValuePair <string, string>("AreaCode", AreaCode.Value.ToString()));
            }

            if (Contains != null)
            {
                p.Add(new KeyValuePair <string, string>("Contains", Contains));
            }

            if (SmsEnabled != null)
            {
                p.Add(new KeyValuePair <string, string>("SmsEnabled", SmsEnabled.Value.ToString().ToLower()));
            }

            if (MmsEnabled != null)
            {
                p.Add(new KeyValuePair <string, string>("MmsEnabled", MmsEnabled.Value.ToString().ToLower()));
            }

            if (VoiceEnabled != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceEnabled", VoiceEnabled.Value.ToString().ToLower()));
            }

            if (ExcludeAllAddressRequired != null)
            {
                p.Add(new KeyValuePair <string, string>("ExcludeAllAddressRequired", ExcludeAllAddressRequired.Value.ToString().ToLower()));
            }

            if (ExcludeLocalAddressRequired != null)
            {
                p.Add(new KeyValuePair <string, string>("ExcludeLocalAddressRequired", ExcludeLocalAddressRequired.Value.ToString().ToLower()));
            }

            if (ExcludeForeignAddressRequired != null)
            {
                p.Add(new KeyValuePair <string, string>("ExcludeForeignAddressRequired", ExcludeForeignAddressRequired.Value.ToString().ToLower()));
            }

            if (Beta != null)
            {
                p.Add(new KeyValuePair <string, string>("Beta", Beta.Value.ToString().ToLower()));
            }

            if (NearNumber != null)
            {
                p.Add(new KeyValuePair <string, string>("NearNumber", NearNumber.ToString()));
            }

            if (NearLatLong != null)
            {
                p.Add(new KeyValuePair <string, string>("NearLatLong", NearLatLong));
            }

            if (Distance != null)
            {
                p.Add(new KeyValuePair <string, string>("Distance", Distance.Value.ToString()));
            }

            if (InPostalCode != null)
            {
                p.Add(new KeyValuePair <string, string>("InPostalCode", InPostalCode));
            }

            if (InRegion != null)
            {
                p.Add(new KeyValuePair <string, string>("InRegion", InRegion));
            }

            if (InRateCenter != null)
            {
                p.Add(new KeyValuePair <string, string>("InRateCenter", InRateCenter));
            }

            if (InLata != null)
            {
                p.Add(new KeyValuePair <string, string>("InLata", InLata));
            }

            if (InLocality != null)
            {
                p.Add(new KeyValuePair <string, string>("InLocality", InLocality));
            }

            if (FaxEnabled != null)
            {
                p.Add(new KeyValuePair <string, string>("FaxEnabled", FaxEnabled.Value.ToString().ToLower()));
            }

            if (PageSize != null)
            {
                p.Add(new KeyValuePair <string, string>("PageSize", PageSize.ToString()));
            }

            return(p);
        }