예제 #1
0
        public void UpdateNumberLeaseConfig()
        {
            const string number = "12132041238";
            var          config = Client.NumberLeasesApi.GetConfig(number, "number,configType,callTrackingConfig");

            Assert.IsNull(config.IvrInboundConfig);
            Assert.AreEqual(NumberConfig.NumberConfigType.TRACKING, config.ConfigType);
            CallTrackingConfig callTrackingConfig = new CallTrackingConfig();

            callTrackingConfig.Recorded        = true;
            callTrackingConfig.Screen          = true;
            callTrackingConfig.TransferNumbers = new List <string> {
                "12132212384"
            };
            callTrackingConfig.Voicemail             = true;
            callTrackingConfig.IntroSoundId          = 9643523003;
            callTrackingConfig.VoicemailSoundId      = 9643523003;
            callTrackingConfig.FailedTransferSoundId = 9643523003;
            callTrackingConfig.WhisperSoundId        = 9643523003;

            WeeklySchedule weeklySchedule = new WeeklySchedule
            {
                StartTimeOfDay = new LocalTime {
                    Hour = 1, Minute = 1, Second = 1
                },
                StopTimeOfDay = new LocalTime {
                    Hour = 2, Minute = 2, Second = 2
                },
                TimeZone   = "America/New_York",
                DaysOfWeek = new HashSet <DayOfWeek> {
                    DayOfWeek.MONDAY, DayOfWeek.FRIDAY, DayOfWeek.SATURDAY
                }
            };

            callTrackingConfig.WeeklySchedule = weeklySchedule;

            GoogleAnalytics googleAnalytics = new GoogleAnalytics
            {
                Category        = "Sales",
                GoogleAccountId = "UA-12345-26",
                Domain          = "testDomain"
            };

            callTrackingConfig.GoogleAnalytics = googleAnalytics;

            config.CallTrackingConfig = callTrackingConfig;
            config.ConfigType         = NumberConfig.NumberConfigType.TRACKING;

            Client.NumberLeasesApi.UpdateConfig(config);
            config = Client.NumberLeasesApi.GetConfig(number);
            Assert.AreEqual(config.ConfigType, NumberConfig.NumberConfigType.TRACKING);
            Assert.AreEqual(config.Number, number);
            Assert.NotNull(config.CallTrackingConfig);
            System.Console.WriteLine(config);

            config = Client.NumberLeasesApi.GetConfig(number, "callTrackingConfig,configType");
            Assert.IsNotNull(config.CallTrackingConfig);
            Assert.IsNull(config.Number);
            Assert.AreEqual(NumberConfig.NumberConfigType.TRACKING, config.ConfigType);
        }
예제 #2
0
 internal static CfCallTrackingConfig FromCallTrackingConfig(CallTrackingConfig source)
 {
     return(source == null ? null : new CfCallTrackingConfig(source.id, source.TransferNumber,
                                                             source.Screen, source.Record, source.IntroSoundId, source.WhisperSoundId));
 }
    public static void Main(string[] args)
    {
        var client = new CallfireClient("api_login", "api_password");
        // create new call tracking config
        var callTrackingConfig = new CallTrackingConfig
        {
            Screen                = false,
            Recorded              = true,
            Voicemail             = true,
            IntroSoundId          = 10004001,
            WhisperSoundId        = 10005002,
            VoicemailSoundId      = 10006003,
            FailedTransferSoundId = 10007004,
            TransferNumbers       = new List <string> {
                "12135551122", "12135551189"
            },
            WeeklySchedule = new WeeklySchedule()
            {
                StartTimeOfDay = new LocalTime {
                    Hour = 10, Minute = 0, Second = 0
                },
                StopTimeOfDay = new LocalTime {
                    Hour = 18, Minute = 0, Second = 0
                },
                DaysOfWeek = new HashSet <DayOfWeek> {
                    DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, DayOfWeek.FRIDAY
                },
                TimeZone = "America/New_York"
            },
            GoogleAnalytics = new GoogleAnalytics()
            {
                Domain          = "domain - name",
                GoogleAccountId = "UA - XXXXX - 2X",
                Category        = "Sales"
            }
        };

        // OR create IVR config
        IvrInboundConfig = new IvrInboundConfig
        {
            DialplanXml = @"
                <dialplan name=""Root"">
                    <menu maxDigits=""1"" timeout=""3500"" name=""Live"">
                        <play type=""tts"" voice=""female1"">
                            Hello this is AB Advertising, please press 1 to transfer to our sales representative,
                            press 2 to contact clients support.
                        </play>
                        <keypress pressed=""1"">
                             <!-- user pressed 1, store this data in 'selected_menu' variable -->
                            <stash varname=""selected_menu"">sales</stash>
                            <play type=""tts"" voice=""female1"">
                                You will be transferred to sales representative in a moment. Please wait.
                            </play>
                            <transfer callerid=""${call.callerid}"" musiconhold=""blues"" mode=""ringall"">
                                15550004455
                            </transfer>
                        </keypress>
                        <keypress pressed=""2"" name=""kp_become_volonteer"">
                             <!-- user pressed 2, store this data in 'selected_menu' variable -->
                            <stash varname=""selected_menu"">support</stash>
                            <play type=""tts"" voice=""female1"">
                                You will be transferred to clients support. Please wait.
                            </play>
                            <transfer callerid=""${call.callerid}"" musiconhold=""blues"" mode=""ringall"">
                                15550005500
                            </transfer>
                        </keypress>
                         <!-- if pressed key is not specified in menu replay Live menu -->
                        <keypress pressed=""default"" name=""incorrect_Selection"">
                            <play type=""tts"" voice=""female1"">That is not a valid selection. Please try again.</play>
                            <goto name=""replay_Live"">Live</goto>
                        </keypress>
                    </menu>
                    <play type=""tts"" voice=""female1"">
                        Thank you for calling us. Have a good day.
                    </play>
                    <hangup name=""Hangup""/>
                </dialplan>
            "
        };

        NumberConfig config = new NumberConfig
        {
            Number = "19206596476",
            // depends on what type of configuration your need assign TRACKING or IVR config
            ConfigType         = NumberConfig.NumberConfigType.TRACKING,
            CallTrackingConfig = callTrackingConfig
                                 // ConfigType = NumberConfig.NumberConfigType.IVR,
                                 // CallTrackingConfig = IvrInboundConfig
        };

        client.NumberLeasesApi.UpdateConfig(config);
    }