Defnies an endoint for transfer and redirects.
        /// <summary>
        /// Class constructor.
        /// </summary>
        /// <param name="json">Session JSON submitted from Tropo platform.</param>
        public Session(string json)
        {
            JObject session = JObject.Parse(json);
            AccountId = (string)session["session"]["accountId"];
            Id = (string)session["session"]["id"];
            InitialText = (string)session["session"]["initialText"];
            Timestamp = (string)session["session"]["timestamp"];
            UserType = (string)session["session"]["userType"];

            if (session["session"]["from"] != null)
            {
                string fromId = (string)session["session"]["from"]["id"];
                string fromName = (string)session["session"]["from"]["name"];
                string fromNetwork = (string)session["session"]["from"]["network"];
                string fromChannel = (string)session["session"]["from"]["channel"];
                From = new Endpoint(fromId, fromChannel, fromName, fromNetwork);
            }

            if (session["session"]["to"] != null)
            {
                string toId = (string)session["session"]["to"]["id"];
                string toName = (string)session["session"]["to"]["name"];
                string toNetwork = (string)session["session"]["to"]["network"];
                string toChannel = (string)session["session"]["to"]["channel"];
                To = new Endpoint(toId, toChannel, toName, toNetwork);
            }

            if (session["session"]["parameters"] != null)
            {
                Parameters = new NameValueCollection();
                JToken _parameter = session["session"]["parameters"].First;

                while (_parameter != null)
                {
                    JProperty property = (JProperty)_parameter;
                    Parameters.Add(property.Name, (String)property.Value);
                    _parameter = _parameter.Next;
                }
            }

            if (session["session"]["headers"] != null)
            {
                Headers = new NameValueCollection();
                JToken _header = session["session"]["headers"].First;

                while (_header != null)
                {
                    JProperty property = (JProperty)_header;
                    Headers.Add(property.Name, property.Value.ToString());
                    _header = _header.Next;
                }
            }

        }
Ejemplo n.º 2
0
        /// <summary>
        /// Class constructor.
        /// </summary>
        /// <param name="JSON">Session JSON submitted from Tropo platform.</param>
        public Session(string JSON)
        {
            JObject session = JObject.Parse(JSON);
            this._accountId = (string)session["session"]["accountId"];
            this._id = (string)session["session"]["id"];
            this._initialText = (string)session["session"]["initialText"];
            this._timestamp = (string)session["session"]["timestamp"];
            this._userType = (string)session["session"]["userType"];

            string from_id = (string)session["session"]["from"]["id"];
            string from_name = (string)session["session"]["from"]["name"];
            string from_network = (string)session["session"]["from"]["from"];
            string from_channel = (string)session["session"]["from"]["channel"];
            this._from = new Endpoint(from_id, from_channel, from_name, from_network);

            string to_id = (string)session["session"]["to"]["id"];
            string to_name = (string)session["session"]["to"]["name"];
            string to_network = (string)session["session"]["to"]["from"];
            string to_channel = (string)session["session"]["to"]["channel"];
            this._to = new Endpoint(to_id, to_channel, to_name, to_network);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// A shortcut method to create a session, say something, and hang up, all in one step. 
        /// This is particularly useful for sending out a quick SMS or IM. 
        /// </summary>
        /// <param name="say">This determines what is played or sent to the caller.</param>
        /// <param name="to">The destination to make a call to or send a message to.</param>
        /// <param name="answerOnMedia">If this is set to true, the call will be considered "answered" and audio will begin playing as soon as media is received from the far end.</param>
        /// <param name="channel">This defines the channel used to place new calls.</param>
        /// <param name="from">An Endpoint object representing who the call is from.</param>
        /// <param name="name">Identifies the return value of a Message, so you know the context for the returned information.</param>
        /// <param name="network">Network is used mainly by the text channels; values can be SMS when sending a text message, or a valid IM network name such as AIM, MSN, JABBER, YAHOO and GTALK.</param>
        /// <param name="required">Determines whether Tropo should move on to the next action.</param>
        /// <param name="timeout">The amount of time Tropo will wait, in seconds, after sending or playing the prompt for the user to begin a response.</param>
        public void message(Say say, ArrayList to, bool? answerOnMedia, string channel, Endpoint from, string name, string network, bool? required, float? timeout)
        {
            Message message = new Message();
            message.say = say;
            message.to = to;
            message.answerOnMedia = answerOnMedia;
            message.channel = channel;
            message.from = from;
            message.name = name;
            message.network = network;
            message.required = required;
            message.timeout = timeout;
            message.voice = String.IsNullOrEmpty(this.Voice) ? null : this.Voice;

            serialize(message, "message");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Transfers an already answered call to another destination / phone number.
        /// Call may be transferred to another phone number or SIP address, which is set through the "to" parameter and is in URL format.
        /// </summary>
        /// <param name="answerOnMedia">If this is set to true, the call will be considered "answered" and audio will begin playing as soon as media is received from the far end.</param>
        /// <param name="choices">The grammar to use in recognizing and validating input.</param>
        /// <param name="from">An Endpoint object representing who the call is from.</param>
        /// <param name="on">An On object.</param>
        /// <param name="ringRepeat">The number of rings to allow on the outbound call attempt.</param>
        /// <param name="timeout">The amount of time Tropo will wait, in seconds, after sending or playing the prompt for the user to begin a response.</param>
        /// <param name="to">The new destination for the incoming call as a URL.</param>
        public void transfer(bool? answerOnMedia, Choices choices, Endpoint from, On on, int? ringRepeat, float? timeout, ArrayList to)
        {
            Transfer transfer = new Transfer();
            transfer.answerOnMedia = answerOnMedia;
            transfer.choices = choices;
            transfer.from = from;
            transfer.on = on;
            transfer.ringRepeat = ringRepeat;
            transfer.timeout = timeout;
            transfer.to = to;

            serialize(transfer, "transfer");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Transfers an already answered call to another destination / phone number.
        /// Call may be transferred to another phone number or SIP address, which is set through the "to" parameter and is in URL format.
        /// </summary>
        /// <param name="answerOnMedia">If this is set to true, the call will be considered "answered" and audio will begin playing as soon as media is received from the far end.</param>
        /// <param name="choices">The grammar to use in recognizing and validating input.</param>
        /// <param name="from">An Endpoint object representing who the call is from.</param>
        /// <param name="on">An On object.</param>
        /// <param name="ringRepeat">The number of rings to allow on the outbound call attempt.</param>
        /// <param name="timeout">The amount of time Tropo will wait, in seconds, after sending or playing the prompt for the user to begin a response.</param>
        /// <param name="to">The new destination for the incoming call as a URL.</param>
        public void Transfer(bool? answerOnMedia, Choices choices, Endpoint from, On on, float? timeout,  IEnumerable<String> to)
        {
            Transfer transfer = new Transfer();
            transfer.AnswerOnMedia = answerOnMedia;
            transfer.Choices = choices;
            transfer.From = from;
            transfer.On = on;
            transfer.Timeout = timeout;
            transfer.To = to;

            Serialize(transfer, "transfer");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Places a call or sends an an IM, Twitter, or SMS message. To start a call, use the Session API to tell Tropo to launch your code.
        /// </summary>
        /// <param name="to">An ArryList containing recipients to call.</param>
        /// <param name="from">An Endpoint object representing who the call is from.</param>
        /// <param name="network">Network is used mainly by the text channels; values can be SMS when sending a text message, or a valid IM network name such as AIM, MSN, JABBER, YAHOO and GTALK.</param>
        /// <param name="channel">This defines the channel used to place new calls.</param>
        /// <param name="answerOnMedia">If this is set to true, the call will be considered "answered" and audio will begin playing as soon as media is received from the far end </param>
        /// <param name="timeout">The amount of time Tropo will wait, in seconds, after sending or playing the prompt for the user to begin a response.</param>
        /// <param name="headers">This contains the Session Initiation Protocol (SIP) Headers for the current session.</param>
        /// <param name="recording">This is a shortcut to allow you to start call recording as soon as the call is answered. </param>      
        public void call(ArrayList to, Endpoint from, string network, string channel, bool? answerOnMedia, float? timeout, Hashtable headers, StartRecording recording)
        {
            Call call = new Call();
            call.to = to;
            call.from = from;
            call.network = network;
            call.channel = channel;
            call.answerOnMedia = answerOnMedia;
            call.timeout = timeout;
            call.headers = headers;
            call.recording = recording;

            serialize(call, "call");
        }
Ejemplo n.º 7
0
        /// <summary>
        /// A shortcut method to create a session, say something, and hang up, all in one step. 
        /// This is particularly useful for sending out a quick SMS or IM. 
        /// </summary>
        /// <param name="say">This determines what is played or sent to the caller.</param>
        /// <param name="to">The destination to make a call to or send a message to.</param>
        /// <param name="answerOnMedia">If this is set to true, the call will be considered "answered" and audio will begin playing as soon as media is received from the far end.</param>
        /// <param name="channel">This defines the channel used to place new calls.</param>
        /// <param name="from">An Endpoint object representing who the call is from.</param>
        /// <param name="name">Identifies the return value of a Message, so you know the context for the returned information.</param>
        /// <param name="network">Network is used mainly by the text channels; values can be SMS when sending a text message, or a valid IM network name such as AIM, MSN, JABBER, YAHOO and GTALK.</param>
        /// <param name="required">Determines whether Tropo should move on to the next action.</param>
        /// <param name="timeout">The amount of time Tropo will wait, in seconds, after sending or playing the prompt for the user to begin a response.</param>
        public void Message(Say say, IEnumerable<String> to, bool? answerOnMedia, string channel, Endpoint from, string name, string network, bool? required, float? timeout)
        {
            Message message = new Message();
            message.Say = say;
            message.To = to;
            message.AnswerOnMedia = answerOnMedia;
            message.Channel = channel;
            message.From = from;
            message.Name = name;
            message.Network = network;
            message.Required = required;
            message.Timeout = timeout;
            message.Voice = String.IsNullOrEmpty(this.Voice) ? null : this.Voice;

            Serialize(message, "message");
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Places a call or sends an an IM, Twitter, or SMS message. To start a call, use the Session API to tell Tropo to launch your code.
        /// </summary>
        /// <param name="to">The party(ies)to call.</param>
        /// <param name="from">An Endpoint object representing who the call is from.</param>
        /// <param name="network">Network is used mainly by the text channels; values can be SMS when sending a text message, or a valid IM network name such as AIM, MSN, JABBER, YAHOO and GTALK.</param>
        /// <param name="channel">This defines the channel used to place new calls.</param>
        /// <param name="answerOnMedia">If this is set to true, the call will be considered "answered" and audio will begin playing as soon as media is received from the far end </param>
        /// <param name="timeout">The amount of time Tropo will wait, in seconds, after sending or playing the prompt for the user to begin a response.</param>
        /// <param name="headers">This contains the Session Initiation Protocol (SIP) Headers for the current session.</param>
        /// <param name="recording">This is a shortcut to allow you to start call recording as soon as the call is answered. </param>      
        public void Call(IEnumerable<String> to, Endpoint from, string network, string channel, bool? answerOnMedia, float? timeout, IDictionary<String, String> headers, StartRecording recording)
        {
            Call call = new Call();
            call.To = to;
            call.From = from;
            call.Network = network;
            call.Channel = channel;
            call.AnswerOnMedia = answerOnMedia;
            call.Timeout = timeout;
            call.Headers = headers;
            call.Recording = recording;

            Serialize(call, "call");
        }
Ejemplo n.º 9
0
        public void testMessageUseAllOptions()
        {
            Say say = new Say("This is an announcement");
            Tropo tropo = new Tropo();
            tropo.Voice = Voice.British_English_female;
            Endpoint from = new Endpoint("3055551212", Channel.voice, "unknown", Network.pstn);
            ArrayList to = new ArrayList();
            to.Add("3055195825");
            tropo.message(say, to, false, Channel.text, from, "foo", Network.sms, true, 10);

            Assert.AreEqual(this.messageJsonAllOptions, TropoJSON.render(tropo));
        }
Ejemplo n.º 10
0
        public void testMessageFromObject()
        {
            Say say = new Say("This is an announcement");
            Endpoint from = new Endpoint("3055551212", null, null, null);
            Message message = new Message();
            ArrayList to = new ArrayList();
            to.Add("3055195825");
            message.say = say;
            message.to = to;
            message.from = from;
            message.answerOnMedia = false;
            message.channel = Channel.text;
            message.network = Network.sms;
            message.timeout = 10;

            Tropo tropo = new Tropo();
            tropo.Voice = Voice.British_English_female;
            tropo.message(message);

            Assert.AreEqual(this.messageJson, TropoJSON.render(tropo));
        }
Ejemplo n.º 11
0
        public void testMessage()
        {
            Say say = new Say("This is an announcement");
            Tropo tropo = new Tropo();
            tropo.Voice = Voice.British_English_female;
            Endpoint from = new Endpoint("3055551212", null, null, null);
            ArrayList to = new ArrayList();
            to.Add("3055195825");
            tropo.message(say, to, false, Channel.text, from, null, Network.sms, null, 10);

            Assert.AreEqual(this.messageJson, TropoJSON.render(tropo));
        }