Exemple #1
0
        public void example_test_tokenization()
        {
            RequestMap parameters = new RequestMap();

            parameters.Set("tokenRequestorId", "12345678901");
            parameters.Set("requestId", "123456");
            parameters.Set("tokenType", "CLOUD");
            parameters.Set("taskId", "123456");

            parameters.Set("cardInfo.encryptedData.source", "CARD_ON_FILE");
            parameters.Set("cardInfo.encryptedData.accountNumber", "5123456789012345");
            parameters.Set("cardInfo.encryptedData.expiryMonth", "12");
            parameters.Set("cardInfo.encryptedData.expiryYear", "18");
            parameters.Set("cardInfo.encryptedData.securityCode", "123");
            parameters.Set("cardInfo.encryptedData.billingAddress.line", "100 1st Street");
            parameters.Set("cardInfo.encryptedData.billingAddress.line2", "Apt. 4B");
            parameters.Set("cardInfo.encryptedData.billingAddress.city", "St. Louis");
            parameters.Set("cardInfo.encryptedData.billingAddress.countrySubdivision", "MO");
            parameters.Set("cardInfo.encryptedData.billingAddress.postalCode", "61000");
            parameters.Set("cardInfo.encryptedData.billingAddress.country", "USA");



            TokenActivation response = TokenActivation.Create(parameters);

            Assert.That("APPROVED", Is.EqualTo(response["decision"]).IgnoreCase);
        }
Exemple #2
0
        public void TestContentTypeOverride()
        {
            RequestMap        requestMap  = new RequestMap("{\n\"id\":\"1\"\n}");
            RequestMap        responseMap = new RequestMap("{\"Account\":{\"Status\":\"true\",\"Listed\":\"true\",\"ReasonCode\":\"S\",\"Reason\":\"STOLEN\"}}");
            TestApiController controller  = new TestApiController();

            controller.SetRestClient(mockClient(HttpStatusCode.OK, responseMap));

            // new Tuple<string, string, List<string>, List<string>>("/test1", null, headerList, queryList);
            var config   = new OperationConfig("/test1", "create", headerList, queryList);
            var metadata = new OperationMetadata("0.0.1", "http://locahost:8081", null, true, "text/json");

            RestyRequest request = controller.GetRequest(config, metadata, new TestBaseObject(requestMap));

            Assert.AreEqual("http://locahost:8081/test1", request.AbsoluteUrl.ToString());
            Assert.AreEqual(true, request.HasBody);
            Assert.AreEqual("POST", request.Method.ToString());
            Assert.AreEqual(true, request.Parameters.Exists(i => i.Name.Equals("Content-Type")));
            Assert.AreEqual(true, request.Parameters.Exists(i => i.Name.Equals("Content-Type")));

            Assert.AreEqual("text/json; charset=utf-8", request.Parameters.Find(i => i.Name.Equals("Accept")).Value.ToString());
            Assert.AreEqual("text/json; charset=utf-8", request.Parameters.Find(i => i.Name.Equals("Content-Type")).Value.ToString());



            String authentication = request.Parameters.Find(i => i.Name.Equals("Authorization")).Value.ToString();

            Assert.AreEqual(true, authentication.Contains("oauth_body_hash"));
        }
Exemple #3
0
 public static void assertEqual(List <string> ignoreAsserts, RequestMap response, String key, String expectedValue)
 {
     if (!ignoreAsserts.Contains(key))
     {
         BaseTest.assert(expectedValue, response.Get(key));
     }
 }
Exemple #4
0
        public void TesNestedAdd()
        {
            RequestMap map = new RequestMap();

            map.Add("key1.key1", "value1");

            Assert.AreEqual(1, map.Count);
            //checl is it finds the key
            Assert.IsTrue(map.ContainsKey("key1"));
            //check if it find the nested keys
            Assert.IsTrue(map.ContainsKey("key1.key1"));
            // check if it find returns the correct value
            Assert.AreEqual("value1", map ["key1.key1"]);
            // check if the first level map contains only one value
            Assert.AreNotSame(1, ((Dictionary <String, Object>)map["key1"]).Count);


            map.Add("key1.key2", "value2");

            Assert.AreEqual(1, map.Count);
            //checl is it finds the key
            Assert.IsTrue(map.ContainsKey("key1"));
            //check if it find the nested keys
            Assert.IsTrue(map.ContainsKey("key1.key2"));
            // check if it find returns the correct value
            Assert.AreEqual("value2", map ["key1.key2"]);
            // check if the first level map contains only one value
            Assert.AreNotSame(2, ((Dictionary <String, Object>)map["key1"]).Count);
        }
Exemple #5
0
        public void ValidateRequestMapFieldsTest()
        {
            var validatedRequestMap = new RequestMap
            {
                ClientId  = "1",
                RequestId = "1",
                Name      = "Bulka i chleb",
                Quantity  = "5",
                Price     = "10.3"
            };
            var request = validatedRequestMap.ValidateFields();

            Assert.IsNotNull(request);

            var NotValidatedRequestMap = new RequestMap
            {
                ClientId  = "1 vv",
                RequestId = "1",
                Name      = "Bulka i chleb",
                Quantity  = "5",
                Price     = "10.3"
            };

            request = validatedRequestMap.ValidateFields();

            Assert.IsNull(request);
        }
Exemple #6
0
        public void TestAddIndexed()
        {
            RequestMap map = new RequestMap();

            map.Add("map[].name", "name1");
            map.Add("map[].name", "name2");
            map.Add("map[].name", "name3");

            Assert.AreEqual(1, map.Count);

            Assert.AreNotSame(1, ((List <Dictionary <String, Object> >)map["map"]).Count);
            //checl is it finds the key
            Assert.IsTrue(map.ContainsKey("map"));
            Assert.IsTrue(map.ContainsKey("map[0]"));
            Assert.IsTrue(map.ContainsKey("map[1]"));
            Assert.IsTrue(map.ContainsKey("map[2]"));
            Assert.IsFalse(map.ContainsKey("map[3]"));


            Assert.AreEqual("name1", map ["map[0].name"]);
            Assert.AreEqual("name2", map ["map[1].name"]);
            Assert.AreEqual("name3", map ["map[2].name"]);

            // check if the first level map contains only one value
            Assert.AreNotSame(1, ((Dictionary <String, Object>)map ["map[0]"]).Count);
            Assert.AreNotSame(1, ((Dictionary <String, Object>)map ["map[1]"]).Count);
            Assert.AreNotSame(1, ((Dictionary <String, Object>)map ["map[2]"]).Count);
        }
        public void example_merchants_Test()
        {
            RequestMap parameters = new RequestMap();

            parameters.Set("Details", "acceptance.paypass");
            parameters.Set("PageOffset", "0");
            parameters.Set("PageLength", "5");
            parameters.Set("Latitude", "38.53463");
            parameters.Set("Longitude", "-90.286781");



            MerchantLocations response = MerchantLocations.Query(parameters);

            TestUtil.assert("0", response["Merchants.PageOffset"]);
            TestUtil.assert("3", response["Merchants.TotalCount"]);
            TestUtil.assert("36564", response["Merchants.Merchant[0].Id"]);
            TestUtil.assert("Merchant 36564", response["Merchants.Merchant[0].Name"]);
            TestUtil.assert("7 - Dry Cleaners And Laundry Services", response["Merchants.Merchant[0].Category"]);
            TestUtil.assert("Merchant 36564", response["Merchants.Merchant[0].Location.Name"]);
            TestUtil.assert("0.9320591049747101", response["Merchants.Merchant[0].Location.Distance"]);
            TestUtil.assert("MILE", response["Merchants.Merchant[0].Location.DistanceUnit"]);
            TestUtil.assert("3822 West Fork Street", response["Merchants.Merchant[0].Location.Address.Line1"]);
            TestUtil.assert("Great Falls", response["Merchants.Merchant[0].Location.Address.City"]);
            TestUtil.assert("51765", response["Merchants.Merchant[0].Location.Address.PostalCode"]);
            TestUtil.assert("Country Subdivision 517521", response["Merchants.Merchant[0].Location.Address.CountrySubdivision.Name"]);
            TestUtil.assert("Country Subdivision Code 517521", response["Merchants.Merchant[0].Location.Address.CountrySubdivision.Code"]);
            TestUtil.assert("Country 5175215", response["Merchants.Merchant[0].Location.Address.Country.Name"]);
            TestUtil.assert("Country Code 5175215", response["Merchants.Merchant[0].Location.Address.Country.Code"]);
            TestUtil.assert("38.52114017591121", response["Merchants.Merchant[0].Location.Point.Latitude"]);
            TestUtil.assert("-90.28678100000002", response["Merchants.Merchant[0].Location.Point.Longitude"]);
            TestUtil.assert("true", response["Merchants.Merchant[0].Acceptance.PayPass.Register"]);
        }
Exemple #8
0
        public void get_user_query_Test()
        {
            Assert.Inconclusive("SKIPPED");
            String id = "1";


            RequestMap parameters = new RequestMap();

            parameters.Set("min", "1");
            parameters.Set("max", "10");



            User response = User.Read(id, parameters);

            Assert.That("1-770-736-8031", Is.EqualTo(response["phone"].ToString()).IgnoreCase);
            Assert.That("hildegard.org", Is.EqualTo(response["website"].ToString()).IgnoreCase);
            Assert.That("true", Is.EqualTo(response["address.instructions.doorman"].ToString()).IgnoreCase);
            Assert.That("2000 Purchase Street", Is.EqualTo(response["address.line1"].ToString()).IgnoreCase);
            Assert.That("NY", Is.EqualTo(response["address.state"].ToString()).IgnoreCase);
            Assert.That("some delivery instructions text", Is.EqualTo(response["address.instructions.text"].ToString()).IgnoreCase);
            Assert.That("1", Is.EqualTo(response["id"].ToString()).IgnoreCase);
            Assert.That("jbloggs", Is.EqualTo(response["username"].ToString()).IgnoreCase);
            Assert.That("*****@*****.**", Is.EqualTo(response["email"].ToString()).IgnoreCase);
            Assert.That("Joe Bloggs", Is.EqualTo(response["name"].ToString()).IgnoreCase);
            Assert.That("10577", Is.EqualTo(response["address.postalCode"].ToString()).IgnoreCase);
            Assert.That("1", Is.EqualTo(response["address.id"].ToString()).IgnoreCase);
            Assert.That("New York", Is.EqualTo(response["address.city"].ToString()).IgnoreCase);
        }
Exemple #9
0
        private static void GetConversion()
        {
            try
            {
                RequestMap map = new RequestMap();
                map.Set("fxDate", "2019-03-22");
                map.Set("transCurr", "USD");
                map.Set("crdhldBillCurr", "BRL");
                map.Set("bankFee", "0");
                map.Set("transAmt", "10");
                ConversionRate response = ConversionRate.Query(map);

                Out(response, "name");                //-->settlement-conversion-rate
                Out(response, "description");         //-->Settlement conversion rate and billing amount
                Out(response, "date");                //-->2017-11-03 03:59:50
                Out(response, "data.conversionRate"); //-->0.57
                Out(response, "data.crdhldBillAmt");  //-->13.11
                Out(response, "data.fxDate");         //-->2016-09-30
                Out(response, "data.transCurr");      //-->ALL
                Out(response, "data.crdhldBillCurr"); //-->DZD
                Out(response, "data.transAmt");       //-->23
                Out(response, "data.bankFee");        //-->5
                Console.ReadKey();
            }
            catch (ApiException e)
            {
                Err("HttpStatus: {0}", e.HttpStatus.ToString());
                Err("Message: {0}", e.Message);
                Err("ReasonCode: {0}", e.ReasonCode);
                Err("Source: {0}", e.Source);
                Console.ReadKey();
            }
        }
Exemple #10
0
        public void Test_list_users_query()
        {
            RequestMap map = new RequestMap();

            map.Set("max", "10");


            List <User> responseList = User.List(map);
            User        response     = responseList[0];

            List <string> ignoreAsserts = new List <string>();

            BaseTest.assertEqual(ignoreAsserts, response, "website", "hildegard.org");
            BaseTest.assertEqual(ignoreAsserts, response, "address.instructions.doorman", "true");
            BaseTest.assertEqual(ignoreAsserts, response, "address.instructions.text", "some delivery instructions text");
            BaseTest.assertEqual(ignoreAsserts, response, "address.city", "New York");
            BaseTest.assertEqual(ignoreAsserts, response, "address.postalCode", "10577");
            BaseTest.assertEqual(ignoreAsserts, response, "address.id", "1");
            BaseTest.assertEqual(ignoreAsserts, response, "address.state", "NY");
            BaseTest.assertEqual(ignoreAsserts, response, "address.line1", "2000 Purchase Street");
            BaseTest.assertEqual(ignoreAsserts, response, "phone", "1-770-736-8031");
            BaseTest.assertEqual(ignoreAsserts, response, "name", "Joe Bloggs");
            BaseTest.assertEqual(ignoreAsserts, response, "id", "1");
            BaseTest.assertEqual(ignoreAsserts, response, "email", "*****@*****.**");
            BaseTest.assertEqual(ignoreAsserts, response, "username", "jbloggs");


            BaseTest.putResponse("list_users_query", responseList[0]);
        }
        public void example_parameters_Test()
        {
            RequestMap parameters = new RequestMap();

            parameters.Set("CurrentRow", "1");
            parameters.Set("Offset", "25");



            Parameters response = Parameters.Query(parameters);

            Assert.That("NO", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[1].Ecomm"]).IgnoreCase);
            Assert.That("Quarterly", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[1].Period"]).IgnoreCase);
            Assert.That("NO", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[2].Ecomm"]).IgnoreCase);
            Assert.That("NO", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[0].Ecomm"]).IgnoreCase);
            Assert.That("U.S. Natural and Organic Grocery Stores", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[0].Sector"]).IgnoreCase);
            Assert.That("U.S. Natural and Organic Grocery Stores", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[1].Sector"]).IgnoreCase);
            Assert.That("U.S. Natural and Organic Grocery Stores", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[2].Sector"]).IgnoreCase);
            Assert.That("Monthly", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[0].Period"]).IgnoreCase);
            Assert.That("Success", Is.EqualTo(response["ParameterList.Message"]).IgnoreCase);
            Assert.That("3", Is.EqualTo(response["ParameterList.Count"].ToString()).IgnoreCase);
            Assert.That("US", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[0].Country"]).IgnoreCase);
            Assert.That("Weekly", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[2].Period"]).IgnoreCase);
            Assert.That("US", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[1].Country"]).IgnoreCase);
            Assert.That("US", Is.EqualTo(response["ParameterList.ParameterArray.Parameter[2].Country"]).IgnoreCase);
        }
Exemple #12
0
        public void TestConstructorDictionary()
        {
            Dictionary <String, Object> testDictionary = new Dictionary <string, object> ();

            testDictionary.Add("boolean", true);
            testDictionary.Add("double", 0.5);
            testDictionary.Add("long", 1000);
            testDictionary.Add("int", 16);
            testDictionary.Add("list", new List <String>()
            {
                "one", "one", "one"
            });
            testDictionary.Add("map", new Dictionary <String, String>()
            {
                { "0", "one" }, { "1", "one" }, { "2", "one" }
            });

            RequestMap map = new RequestMap(testDictionary);

            Assert.AreEqual(6, map.Count);
            Assert.IsTrue(map.ContainsKey("boolean"));
            Assert.IsTrue(map.ContainsKey("double"));
            Assert.IsTrue(map.ContainsKey("long"));
            Assert.IsTrue(map.ContainsKey("int"));
            Assert.IsTrue(map.ContainsKey("list"));
            Assert.IsTrue(map.ContainsKey("map"));

            Assert.AreEqual(true, map ["boolean"]);
            Assert.AreEqual(0.5, map ["double"]);
            Assert.AreEqual(1000, map ["long"]);
            Assert.AreEqual(16, map ["int"]);
            Assert.AreEqual(3, ((List <String>)map ["list"]).Count);
            Assert.AreEqual(3, ((Dictionary <String, Object>)map ["map"]).Count);
        }
Exemple #13
0
        public void Test_get_user()
        {
            RequestMap map = new RequestMap();

            map.Set("id", BaseTest.resolveResponseValue("create_user.id"));

            User response = User.Read("", map);

            List <string> ignoreAsserts = new List <string>();

            ignoreAsserts.Add("address.city");


            BaseTest.assertEqual(ignoreAsserts, response, "website", "hildegard.org");
            BaseTest.assertEqual(ignoreAsserts, response, "address.instructions.doorman", "true");
            BaseTest.assertEqual(ignoreAsserts, response, "address.instructions.text", "some delivery instructions text");
            BaseTest.assertEqual(ignoreAsserts, response, "address.city", "New York");
            BaseTest.assertEqual(ignoreAsserts, response, "address.postalCode", "10577");
            BaseTest.assertEqual(ignoreAsserts, response, "address.id", "1");
            BaseTest.assertEqual(ignoreAsserts, response, "address.state", "NY");
            BaseTest.assertEqual(ignoreAsserts, response, "address.line1", "2000 Purchase Street");
            BaseTest.assertEqual(ignoreAsserts, response, "phone", "1-770-736-8031");
            BaseTest.assertEqual(ignoreAsserts, response, "name", "Joe Bloggs");
            BaseTest.assertEqual(ignoreAsserts, response, "id", "1");
            BaseTest.assertEqual(ignoreAsserts, response, "email", "*****@*****.**");
            BaseTest.assertEqual(ignoreAsserts, response, "username", "jbloggs");


            BaseTest.putResponse("get_user", response);
        }
Exemple #14
0
        public void list_users_query_Test()
        {
            Assert.Inconclusive("SKIPPED");

            RequestMap map = new RequestMap();

            map.Set("max", "10");



            List <User> responseList = User.List(map);
            User        response     = responseList[0];

            Assert.That("1-770-736-8031", Is.EqualTo(response["phone"].ToString()).IgnoreCase);
            Assert.That("hildegard.org", Is.EqualTo(response["website"].ToString()).IgnoreCase);
            Assert.That("true", Is.EqualTo(response["address.instructions.doorman"].ToString()).IgnoreCase);
            Assert.That("2000 Purchase Street", Is.EqualTo(response["address.line1"].ToString()).IgnoreCase);
            Assert.That("NY", Is.EqualTo(response["address.state"].ToString()).IgnoreCase);
            Assert.That("some delivery instructions text", Is.EqualTo(response["address.instructions.text"].ToString()).IgnoreCase);
            Assert.That("1", Is.EqualTo(response["id"].ToString()).IgnoreCase);
            Assert.That("jbloggs", Is.EqualTo(response["username"].ToString()).IgnoreCase);
            Assert.That("*****@*****.**", Is.EqualTo(response["email"].ToString()).IgnoreCase);
            Assert.That("Joe Bloggs", Is.EqualTo(response["name"].ToString()).IgnoreCase);
            Assert.That("10577", Is.EqualTo(response["address.postalCode"].ToString()).IgnoreCase);
            Assert.That("1", Is.EqualTo(response["address.id"].ToString()).IgnoreCase);
            Assert.That("New York", Is.EqualTo(response["address.city"].ToString()).IgnoreCase);
        }
Exemple #15
0
        public void update_user_Test()
        {
            Assert.Inconclusive("SKIPPED");
            RequestMap map = new RequestMap();

            map.Set("id", "1");
            map.Set("phone", "1-770-736-8031");
            map.Set("username", "jbloggs");
            map.Set("website", "hildegard.org");
            map.Set("email", "*****@*****.**");
            map.Set("address.line1", "2000 Purchase Street");
            map.Set("name", "Joe Bloggs");
            map.Set("address.state", "NY");
            map.Set("address.postalCode", "10577");
            map.Set("address.city", "New York");

            User response = new User(map).Update();

            Assert.That("1-770-736-8031", Is.EqualTo(response["phone"].ToString()).IgnoreCase);
            Assert.That("hildegard.org", Is.EqualTo(response["website"].ToString()).IgnoreCase);
            Assert.That("true", Is.EqualTo(response["address.instructions.doorman"].ToString()).IgnoreCase);
            Assert.That("2000 Purchase Street", Is.EqualTo(response["address.line1"].ToString()).IgnoreCase);
            Assert.That("NY", Is.EqualTo(response["address.state"].ToString()).IgnoreCase);
            Assert.That("some delivery instructions text", Is.EqualTo(response["address.instructions.text"].ToString()).IgnoreCase);
            Assert.That("1", Is.EqualTo(response["id"].ToString()).IgnoreCase);
            Assert.That("jbloggs", Is.EqualTo(response["username"].ToString()).IgnoreCase);
            Assert.That("*****@*****.**", Is.EqualTo(response["email"].ToString()).IgnoreCase);
            Assert.That("Joe Bloggs", Is.EqualTo(response["name"].ToString()).IgnoreCase);
            Assert.That("10577", Is.EqualTo(response["address.postalCode"].ToString()).IgnoreCase);
            Assert.That("1", Is.EqualTo(response["address.id"].ToString()).IgnoreCase);
            Assert.That("New York", Is.EqualTo(response["address.city"].ToString()).IgnoreCase);
        }
Exemple #16
0
        public void TestConvertValueToMap()
        {
            RequestMap map = new RequestMap();

            map.Add("level1", "value1");
            Assert.Throws <InvalidCastException> (() => { map.Add("level1.level2", "level2"); });
        }
Exemple #17
0
        public static Object resolveResponseValue(String overrideValue)
        {
            //arizzini: if plain value, return it
            if (overrideValue.StartsWith("val:"))
            {
                return(overrideValue.Substring(4));
            }
            else
            {
                int i = overrideValue.IndexOf(".");

                String name = overrideValue.Substring(0, i);
                String key  = overrideValue.Substring(i + 1);

                if (responses.ContainsKey(name))
                {
                    RequestMap response = responses[name];
                    if (response.ContainsKey(key))
                    {
                        return((Object)response.Get(key));
                    }
                    else
                    {
                        log.Error("Key: " + key + " is not found in the response");
                    }
                }
                else
                {
                    log.Error("Example: " + name + " is not found in the response");
                }

                return(null);
            }
        }
Exemple #18
0
        /// <summary>
        /// Delete an object of type <code>User</code>
        /// </summary>
        /// <param name="id">The unique identifier which is used to identify an User object.</param>
        /// <param name="parameters">additional parameters</param>
        /// <returns> A User object </returns>
        /// <exception cref="ApiCommunicationException"> </exception>
        /// <exception cref="AuthenticationException"> </exception>
        /// <exception cref="InvalidRequestException"> </exception>
        /// <exception cref="NotAllowedException"> </exception>
        /// <exception cref="ObjectNotFoundException"> </exception>
        /// <exception cref="SystemException"> </exception>
        public static User delete200(String id, RequestMap parameters)
        {
            RequestMap map = new RequestMap();

            map.Set("id", id);
            map.AddAll(parameters);
            return(BaseObject.Execute("f6048a68-7ad7-46a4-8bd9-670641c219ac", new User(map)));
        }
        /// <summary>
        /// Delete an object of type <code>MultiplePathUserPost</code>
        /// </summary>
        /// <param name="id">The unique identifier which is used to identify an MultiplePathUserPost object.</param>
        /// <param name="parameters">additional parameters</param>
        /// <returns> A MultiplePathUserPost object </returns>
        /// <exception cref="ApiCommunicationException"> </exception>
        /// <exception cref="AuthenticationException"> </exception>
        /// <exception cref="InvalidRequestException"> </exception>
        /// <exception cref="NotAllowedException"> </exception>
        /// <exception cref="ObjectNotFoundException"> </exception>
        /// <exception cref="SystemException"> </exception>
        public static MultiplePathUserPost Delete(String id, RequestMap parameters)
        {
            RequestMap map = new RequestMap();

            map.Set("id", id);
            map.AddAll(parameters);
            return(BaseObject.Execute("84910aee-b8c5-4d86-b84c-0dc822e6937d", new MultiplePathUserPost(map)));
        }
Exemple #20
0
        /// <summary>
        /// Delete an object of type <code>Post</code>
        /// </summary>
        /// <param name="id">The unique identifier which is used to identify an Post object.</param>
        /// <param name="parameters">additional parameters</param>
        /// <returns> A Post object </returns>
        /// <exception cref="ApiCommunicationException"> </exception>
        /// <exception cref="AuthenticationException"> </exception>
        /// <exception cref="InvalidRequestException"> </exception>
        /// <exception cref="NotAllowedException"> </exception>
        /// <exception cref="ObjectNotFoundException"> </exception>
        /// <exception cref="SystemException"> </exception>
        public static Post Delete(String id, RequestMap parameters)
        {
            RequestMap map = new RequestMap();

            map.Set("id", id);
            map.AddAll(parameters);
            return(BaseObject.Execute("dff1a901-b80d-4cdf-a04b-ae5b084f95fb", new Post(map)));
        }
Exemple #21
0
        public void TestAddIndexedWithOffset()
        {
            RequestMap map = new RequestMap();



            Assert.Throws <ArgumentOutOfRangeException> (() => { map.Add("map[1].name", "name1"); });
        }
Exemple #22
0
        /// <summary>
        /// Delete an object of type <code>User</code>
        /// </summary>
        /// <param name="id">The unique identifier which is used to identify an User object.</param>
        /// <param name="parameters">additional parameters</param>
        /// <returns> A User object </returns>
        /// <exception cref="ApiCommunicationException"> </exception>
        /// <exception cref="AuthenticationException"> </exception>
        /// <exception cref="InvalidRequestException"> </exception>
        /// <exception cref="NotAllowedException"> </exception>
        /// <exception cref="ObjectNotFoundException"> </exception>
        /// <exception cref="SystemException"> </exception>
        public static User delete204(String id, RequestMap parameters)
        {
            RequestMap map = new RequestMap();

            map.Set("id", id);
            map.AddAll(parameters);
            return(BaseObject.Execute("1bce28cd-c900-41b6-ac86-3232903ada1f", new User(map)));
        }
Exemple #23
0
        /// <summary>
        /// Delete an object of type <code>User</code>
        /// </summary>
        /// <param name="id">The unique identifier which is used to identify an User object.</param>
        /// <param name="parameters">additional parameters</param>
        /// <returns> A User object </returns>
        /// <exception cref="ApiCommunicationException"> </exception>
        /// <exception cref="AuthenticationException"> </exception>
        /// <exception cref="InvalidRequestException"> </exception>
        /// <exception cref="NotAllowedException"> </exception>
        /// <exception cref="ObjectNotFoundException"> </exception>
        /// <exception cref="SystemException"> </exception>
        public static User Delete(String id, RequestMap parameters)
        {
            RequestMap map = new RequestMap();

            map.Set("id", id);
            map.AddAll(parameters);
            return(BaseObject.Execute("db10ab01-2198-4abf-ade1-3868cfb3d01c", new User(map)));
        }
Exemple #24
0
        public void TestAddIndexedWithOffset()
        {
            RequestMap map = new RequestMap();



            Assert.DoesNotThrow(() => { map.Add("map[1].name", "name1"); });
        }
Exemple #25
0
        public void Test405_NotAllowedException()
        {
            RequestMap    responseMap = new RequestMap("{\"Errors\":{\"Error\":{\"Source\":\"System\",\"ReasonCode\":\"METHOD_NOT_ALLOWED\",\"Description\":\"Method not Allowed\",\"Recoverable\":\"false\"}}}");
            ApiController controller  = new ApiController();

            controller.SetRestClient(mockClient(HttpStatusCode.MethodNotAllowed, responseMap));

            Assert.Throws <MasterCard.Core.Exceptions.NotAllowedException> (() => controller.execute("create", "test1", new TestBaseObject(responseMap)), "Method not Allowed");
        }
        public void TestAddIndexedWithOffset()
        {
            Assert.Inconclusive("No longer relavant");
            RequestMap map = new RequestMap();



            Assert.Throws <ArgumentOutOfRangeException> (() => { map.Add("map[1].name", "name1"); });
        }
Exemple #27
0
        public void Test401_AuthenticationException()
        {
            RequestMap    responseMap = new RequestMap("{\"Errors\":{\"Error\":[{\"Source\":\"OAuth.ConsumerKey\",\"ReasonCode\":\"INVALID_CLIENT_ID\",\"Description\":\"Oauth customer key invalid\",\"Recoverable\":false,\"Details\":null}]}}");
            ApiController controller  = new ApiController();

            controller.SetRestClient(mockClient(HttpStatusCode.Unauthorized, responseMap));

            Assert.Throws <MasterCard.Core.Exceptions.AuthenticationException> (() => controller.execute("create", "test1", new TestBaseObject(responseMap)), "Oauth customer key invalid");
        }
        public void Test405_NotAllowedException()
        {
            RequestMap    responseMap = new RequestMap("{\"Errors\":{\"Error\":{\"Source\":\"System\",\"ReasonCode\":\"METHOD_NOT_ALLOWED\",\"Description\":\"Method not Allowed\",\"Recoverable\":\"false\"}}}");
            ApiController controller  = new ApiController("0.0.1");

            controller.SetRestClient(mockClient(HttpStatusCode.MethodNotAllowed, responseMap));

            Assert.Throws <NotAllowedException> (() => controller.Execute(new OperationConfig("/test1", "create", new List <string>(), headerList), new OperationMetadata("0.0.1", null), new TestBaseObject(responseMap)), "Method not Allowed");
        }
        public void Test401_AuthenticationException()
        {
            RequestMap    responseMap = new RequestMap("{\"Errors\":{\"Error\":[{\"Source\":\"OAuth.ConsumerKey\",\"ReasonCode\":\"INVALID_CLIENT_ID\",\"Description\":\"Oauth customer key invalid\",\"Recoverable\":false,\"Details\":null}]}}");
            ApiController controller  = new ApiController("0.0.1");

            controller.SetRestClient(mockClient(HttpStatusCode.Unauthorized, responseMap));

            Assert.Throws <AuthenticationException> (() => controller.Execute(new OperationConfig("/test1", "create", new List <string>(), headerList), new OperationMetadata("0.0.1", null), new TestBaseObject(responseMap)), "Oauth customer key invalid");
        }
        public void Test500_InvalidRequestException()
        {
            RequestMap    responseMap = new RequestMap("{\"Errors\":{\"Error\":[{\"Source\":\"OAuth.ConsumerKey\",\"ReasonCode\":\"INVALID_CLIENT_ID\",\"Description\":\"Something went wrong\",\"Recoverable\":false,\"Details\":null}]}}");
            ApiController controller  = new ApiController("0.0.1");

            controller.SetRestClient(mockClient(HttpStatusCode.InternalServerError, responseMap));

            Assert.Throws <MasterCard.Core.Exceptions.SystemException> (() => controller.Execute(new OperationConfig("/test1", "create", new List <string>(), headerList), new OperationMetadata("0.0.1", null), new TestBaseObject(responseMap)), "Something went wrong");
        }