コード例 #1
0
        public void BuyCreditsUsingStoredCreditCard()
        {
            var expectedJson = GetJsonPayload("/credits/creditsApi/buyCredits.json");
            var restRequest  = MockRestResponse(expectedJson);

            var request = new BuyCreditsRequest
            {
                Credits    = 2000,
                CouponCode = "ABX32WE",
                StoredCard = "4533"
            };
            var response = Client.CreditsApi.BuyCredits(request);
            EzTextingResponse <BuyCreditsResponse> ezResponse = new EzTextingResponse <BuyCreditsResponse>(
                "Success", 201, response);

            Assert.That(Serializer.Serialize(ezResponse), Is.EqualTo(expectedJson));

            Assert.AreEqual(Method.POST, restRequest.Value.Method);
            Assert.IsTrue(restRequest.Value.Parameters.Count > 0);
            var bodyParam = restRequest.Value.Parameters[0];

            Assert.AreEqual(ClientConstants.FormEncodedContentType, bodyParam.ContentType);
            Assert.AreEqual(ParameterType.RequestBody, bodyParam.Type);

            Assert.That(bodyParam.Value, Is.StringContaining("User=login"));
            Assert.That(bodyParam.Value, Is.StringContaining("Password=password"));

            Assert.That(bodyParam.Value, Is.StringContaining("NumberOfCredits=2000"));
            Assert.That(bodyParam.Value, Is.StringContaining("CouponCode=ABX32WE"));
            Assert.That(bodyParam.Value, Is.StringContaining("StoredCreditCard=4533"));
        }
コード例 #2
0
        public void BuyCreditsUsingNewCreditCard()
        {
            var expectedJson = GetJsonPayload("/credits/creditsApi/buyCredits.json");
            var restRequest  = MockRestResponse(expectedJson);

            var request = new BuyCreditsRequest
            {
                Credits         = 2000,
                CouponCode      = "ABX32WE",
                FirstName       = "John",
                LastName        = "Doe",
                State           = "LA",
                SecurityCode    = "123",
                ExpirationMonth = "11",
                ExpirationYear  = "2020",
                Number          = "411111111111",
                City            = "LA",
                Country         = "US",
                Street          = "1 Avenue",
                Zip             = "31331",
                Type            = CreditCardType.MasterCard
            };
            var response = Client.CreditsApi.BuyCredits(request);
            EzTextingResponse <BuyCreditsResponse> ezResponse = new EzTextingResponse <BuyCreditsResponse>(
                "Success", 201, response);

            Assert.That(Serializer.Serialize(ezResponse), Is.EqualTo(expectedJson));

            Assert.AreEqual(Method.POST, restRequest.Value.Method);
            Assert.IsTrue(restRequest.Value.Parameters.Count > 0);
            var bodyParam = restRequest.Value.Parameters[0];

            Assert.AreEqual(ClientConstants.FormEncodedContentType, bodyParam.ContentType);
            Assert.AreEqual(ParameterType.RequestBody, bodyParam.Type);

            Assert.That(bodyParam.Value, Is.StringContaining("User=login"));
            Assert.That(bodyParam.Value, Is.StringContaining("Password=password"));

            Assert.That(bodyParam.Value, Is.StringContaining("NumberOfCredits=2000"));
            Assert.That(bodyParam.Value, Is.StringContaining("CouponCode=ABX32WE"));

            Assert.That(bodyParam.Value, Is.StringContaining("FirstName=John"));
            Assert.That(bodyParam.Value, Is.StringContaining("LastName=Doe"));
            Assert.That(bodyParam.Value, Is.StringContaining("State=LA"));
            Assert.That(bodyParam.Value, Is.StringContaining("City=LA"));
            Assert.That(bodyParam.Value, Is.StringContaining("Street=" + "1 Avenue".UrlEncode()));
            Assert.That(bodyParam.Value, Is.StringContaining("Country=US"));
            Assert.That(bodyParam.Value, Is.StringContaining("State=LA"));
            Assert.That(bodyParam.Value, Is.StringContaining("SecurityCode=123"));
            Assert.That(bodyParam.Value, Is.StringContaining("ExpirationMonth=11"));
            Assert.That(bodyParam.Value, Is.StringContaining("ExpirationYear=2020"));
            Assert.That(bodyParam.Value, Is.StringContaining("Number=411111111111"));
            Assert.That(bodyParam.Value, Is.StringContaining("Zip=31331"));
            Assert.That(bodyParam.Value, Is.StringContaining("CreditCardTypeID=MasterCard"));
        }
コード例 #3
0
        public void BuyCreditsUsingStoredCreditCard()
        {
            var request = new BuyCreditsRequest
            {
                Credits    = 2000,
                StoredCard = "1111"
            };
            var response = Client.CreditsApi.BuyCredits(request);

            Console.WriteLine("buy credits with stored card response: " + response);
        }
コード例 #4
0
        public void BuyCreditsUsingNewCreditCard()
        {
            var request = new BuyCreditsRequest
            {
                Credits         = 2000,
                CouponCode      = "ABX32WE",
                FirstName       = "John",
                LastName        = "Doe",
                State           = "LA",
                SecurityCode    = "123",
                ExpirationMonth = "11",
                ExpirationYear  = "2020",
                Number          = "4111111111111111",
                City            = "LA",
                Country         = "US",
                Street          = "1 Avenue",
                Zip             = "31331",
                Type            = CreditCardType.Visa
            };
            var response = Client.CreditsApi.BuyCredits(request);

            Console.WriteLine("buy credits with new card response: " + response);
        }
コード例 #5
0
 /// <summary>
 /// Buys more credits for your account. You may purchase credits using a credit card you have stored in your
 /// Ez Texting account, or you may pass credit card details when you call the API.
 /// </summary>
 /// <param name="request">request object</param>
 /// <returns>amount spent and account balance</returns>
 /// <exception cref="EzTextingApiException">in case error has occurred on server side, check provided error description.</exception>
 /// <exception cref="EzTextingClientException">in case error has occurred in client.</exception>
 public BuyCreditsResponse BuyCredits(BuyCreditsRequest request)
 {
     return(_client.Post <BuyCreditsResponse>(BuyCreditsPath, request).Entry);
 }