Esempio n. 1
0
        /// <summary>
        /// Get the widget session status for the supplied session token.
        /// </summary>
        /// <param name="sessionToken">The session token.</param>
        /// <param name="recipient">The recipient (optional).</param>
        /// <param name="backupCodeIdentifier">The backup code identifier (optional).</param>
        /// <returns><see cref="WidgetSession"/> with the supplied parameters.</returns>
        /// <exception cref="EntityException">Thrown when the session token is empty or null.</exception>
        /// <exception cref="EntityException">Thrown when the recipient and backup code identifier are empty or null.</exception>
        /// <exception cref="EntityException">Thrown when the <see cref="AbstractEntity.parameters"/> of this entity could not be serialized.</exception>
        /// <exception cref="Entity.ValidationExceptions.ValidationException">Thrown when incorrect parameters were sent to the server.</exception>
        /// <exception cref="EntityException">Thrown when the server returns a non-success http status code or an invalid response.</exception>
        public WidgetSession GetWidgetSession(string sessionToken, string recipient = null, string backupCodeIdentifier = null)
        {
            WidgetSession widgetSession = factory.CreateEmptyWidgetSession();

            widgetSession.Populate(sessionToken, recipient, backupCodeIdentifier);
            return(widgetSession);
        }
Esempio n. 2
0
        public void PopulateTestInvalidIdentifier()
        {
            //Arrange
            TwizoClient   client  = new TwizoClient(TwizoTests.apiKey, TwizoTests.apiHost);
            WidgetSession session = new WidgetSession(client);

            //Act
            session.Populate("myMessageId");
        }
Esempio n. 3
0
        public void PopulateTestNull()
        {
            //Arrange
            TwizoClient   client  = new TwizoClient(TwizoTests.apiKey, TwizoTests.apiHost);
            WidgetSession session = new WidgetSession(client);

            //Act
            session.Populate(null);
        }
Esempio n. 4
0
        public void PopulateTest()
        {
            //Arrange
            TwizoClient   client  = new TwizoClient(TwizoTests.apiKey, TwizoTests.apiHost);
            WidgetSession session = new WidgetSession(client);

            session.recipient    = "601151174973";
            session.bodyTemplate = "This is a unit test %token%";
            session.tag          = "Unit tester";
            session.allowedTypes = new[] { WidgetSession.TYPE_SMS };

            //Act
            session.Create();
            var newSession = new WidgetSession(client);

            newSession.Populate(session.sessionToken, session.recipient);

            //Assert
            Assert.AreEqual(newSession.sessionToken, session.sessionToken);
            Assert.AreEqual(newSession.bodyTemplate, session.bodyTemplate);
            Assert.AreEqual(newSession.tag, session.tag);
        }