Exemple #1
0
        public void Given()
        {
            const string username = "******";
            const string password = "******";

            _optOutId         = Guid.NewGuid();
            _accountReference = "EX0123456";
            _receivedAt       = DateTime.UtcNow;
            _phoneNumber      = "44123456789";

            var data = new
            {
                OptOut = new
                {
                    Id               = _optOutId,
                    ReceivedAt       = _receivedAt,
                    AccountReference = _accountReference,
                    From             = new
                    {
                        PhoneNumber = _phoneNumber
                    }
                }
            };

            MockApi.SetEndpoint(new MockEndpoint(200, JsonConvert.SerializeObject(data), "application/json; charset=utf-8"));

            var optOutClient = new OptOutsService(MockApi.Url, new EsendexCredentials(username, password));

            _result  = optOutClient.Add(_accountReference, _phoneNumber);
            _request = MockApi.LastRequest;
        }
Exemple #2
0
        public void Given()
        {
            const string username  = "******";
            const string password  = "******";
            const string recipient = "44123456789";
            var          surveyId  = Guid.NewGuid();

            _errorCode        = "survey_problem";
            _errorDescription = "There was a problem";
            _errorValue       = "THIS VALUE";
            _errorValue2      = "OTHER VALUE";

            var data = new
            {
                errors = new[]
                {
                    new { code = _errorCode, description = _errorDescription, values = new[] { _errorValue, _errorValue2 } }
                }
            };

            MockApi.SetEndpoint(new MockEndpoint(400,
                                                 JsonConvert.SerializeObject(data),
                                                 "application/json; charset=utf-8"));

            var surveysClient = new SurveysService(MockApi.Url, new EsendexCredentials(username, password));

            _result = surveysClient.Send(surveyId, recipient);
        }
        public void Given()
        {
            const string username = "******";
            const string password = "******";

            _recipient = "44123456789";
            _surveyId  = Guid.NewGuid();

            _expectedUrl       = string.Format("/v1.0/surveys/{0}/send", _surveyId);
            _expectedUserAgent = string.Format("Esendex .NET SDK v{0}.{1}.{2}", _version.Major, _version.Minor, _version.Build);

            MockApi.SetEndpoint(new MockEndpoint(200, contentType: "text/plain"));

            var surveysClient = new SurveysService(MockApi.Url, new EsendexCredentials(username, password));

            surveysClient.Send(_surveyId, _recipient);
            _request = MockApi.LastRequest;
        }
Exemple #4
0
        public void Given()
        {
            const string username = "******";
            const string password = "******";

            MockApi.SetEndpoint(new MockEndpoint(_statusCode));

            var optOutClient = new OptOutsService(MockApi.Url, new EsendexCredentials(username, password));

            try
            {
                optOutClient.Add("something", "somethingelse");
            }
            catch (WebException ex)
            {
                _result = ex;
            }
        }
Exemple #5
0
        public void Given()
        {
            const string username  = "******";
            const string password  = "******";
            const string recipient = "44123456789";
            var          surveyId  = Guid.NewGuid();

            MockApi.SetEndpoint(new MockEndpoint(_statusCode));

            var surveysClient = new SurveysService(MockApi.Url, new EsendexCredentials(username, password));

            try
            {
                surveysClient.Send(surveyId, recipient);
            }
            catch (WebException ex)
            {
                _result = ex;
            }
        }
Exemple #6
0
        public void Given()
        {
            const string username = "******";
            const string password = "******";

            var data = new
            {
                StartIndex = 0,
                Count      = 0,
                TotalCount = 0
            };

            _pageSize   = 15;
            _pageNumber = 1;

            MockApi.SetEndpoint(new MockEndpoint(200, JsonConvert.SerializeObject(data), "application/json"));

            var optOutClient = new OptOutsService(MockApi.Url, new EsendexCredentials(username, password));

            _result  = optOutClient.GetAll(_pageNumber, _pageSize);
            _request = MockApi.LastRequest;
        }
Exemple #7
0
        public void Given()
        {
            const string username = "******";
            const string password = "******";

            var data = new
            {
                Errors = new[]
                {
                    new
                    {
                        Code        = _code,
                        Description = _description
                    }
                }
            };

            MockApi.SetEndpoint(new MockEndpoint(400, JsonConvert.SerializeObject(data), "application/json"));

            var optOutClient = new OptOutsService(MockApi.Url, new EsendexCredentials(username, password));

            _result = optOutClient.Add("", "");
        }