Inheritance: IRestAPIType
Exemplo n.º 1
0
        public static void RunMethods()
        {
            //Initialize all variables
            string sHost        = string.Empty;
            string sPrivateKey  = string.Empty;
            string sToken       = string.Empty;
            string sSecureURL   = string.Empty;
            string sVersion     = string.Empty;
            string sContentType = string.Empty;
            string sCustomerID  = string.Empty;
            string sType        = string.Empty;
            string sID          = string.Empty;

            //Provide the parameters for the HTTP Client
            sHost        = "http://apirest.3dcart.com/3dCartWebAPI/v";
            sVersion     = "1";
            sPrivateKey  = "bc6c0b6ae8d1fa40314b65fec3047c8b";
            sToken       = "f244f1d222b5a691db32ff537281121f";
            sSecureURL   = "https://3dcart-nadeem-com.3dcartstores.com";
            sContentType = "application/json";

            //Create the instance of SitRecords class that performs HTTP GET, POST, PUT and DELETE
            RestAPIActions objectClass = new RestAPIActions();

            //For Product
            //sPrivateKey = "57f27035ea3d8aba663f9c1d55bbc3be";
            //sToken = "cfee277cd92d0d45a131dd46fd4351a3";

            //For Order
            //sPrivateKey = "0391a083cd7b6a2fc137ca63a9e1653a";
            //sToken = "0e3bee1903d00f70e6ce57f0fef245ab";

            //For Manufacturer and Distributor
            //sPrivateKey = "b3343cc81e7cd0ff31bca85cb8dbb63c";
            //sToken = "4d11264cdeb5987f6a5044f683698dc3";

            //For Category
            //sPrivateKey = "701bc75f1055f7aaef09d6f9b2479022";
            //sToken = "dea3a5e2032a408441f6248b0ba30cd4";

            //provide all the required parameters for HTTP Client
            objectClass.HttpHost       = sHost;
            objectClass.ServiceVersion = sVersion;
            objectClass.PrivateKey     = sPrivateKey;
            objectClass.Token          = sToken;
            objectClass.SecureURL      = sSecureURL;
            objectClass.ContentType    = sContentType;


            //Specify the type of Rest API
            objectClass.Type = GetRestAPIType(RestAPIType.CustomerGroup);


            //GET

            //objectClass.ID = 2;
            CallFunctions(null, objectClass, ActionType.Get, RestAPIType.CustomerGroup);


            //POST

            //Customer RecordToAdd = new Customer() { Email = "*****@*****.**", Password = "******", BillingFirstName = "Mark", BillingLastName = "Adams" };
            CustomerGroup RecordToAdd = new CustomerGroup()
            {
                Name = "AnotherCustomerGroup121615_01", Description = "CustomerGroup121615_01"
            };

            CallFunctions(RecordToAdd, objectClass, ActionType.Add, RestAPIType.CustomerGroup);
            Type a = typeof(CustomerGroup);


            //PUT
            objectClass.ID = 2;
            //Customer RecordToUpdate = new Customer() { BillingFirstName = "Andrew", BillingLastName = "Williams", CustomerID = objectClass.ID };
            CustomerGroup RecordToUpdate = new CustomerGroup()
            {
                CustomerGroupID = objectClass.ID, Description = "SupportCustomers"
            };

            CallFunctions(RecordToUpdate, objectClass, ActionType.Update, RestAPIType.CustomerGroup);


            //DELETE
            objectClass.ID = 4;
            //CallFunctions(null, objectClass, ActionType.Delete );
        }
Exemplo n.º 2
0
        public static void RunMethods()
        {
            //Initialize all variables
            string sHost = string.Empty;
            string sPrivateKey = string.Empty;
            string sToken = string.Empty;
            string sSecureURL = string.Empty;
            string sVersion = string.Empty;
            string sContentType = string.Empty;
            string sCustomerID = string.Empty;
            string sType = string.Empty;
            string sID = string.Empty;

            //Provide the parameters for the HTTP Client 
            sHost = "http://apirest.3dcart.com/3dCartWebAPI/v";
            sVersion = "1";
            sPrivateKey = "bc6c0b6ae8d1fa40314b65fec3047c8b";
            sToken = "f244f1d222b5a691db32ff537281121f";
            sSecureURL = "https://3dcart-nadeem-com.3dcartstores.com";
            sContentType = "application/json";

            //Create the instance of SitRecords class that performs HTTP GET, POST, PUT and DELETE
            RestAPIActions objectClass = new RestAPIActions();

            //For Product
            //sPrivateKey = "57f27035ea3d8aba663f9c1d55bbc3be";
            //sToken = "cfee277cd92d0d45a131dd46fd4351a3";

            //For Order
            //sPrivateKey = "0391a083cd7b6a2fc137ca63a9e1653a";
            //sToken = "0e3bee1903d00f70e6ce57f0fef245ab";

            //For Manufacturer and Distributor
            //sPrivateKey = "b3343cc81e7cd0ff31bca85cb8dbb63c";
            //sToken = "4d11264cdeb5987f6a5044f683698dc3";

            //For Category
            //sPrivateKey = "701bc75f1055f7aaef09d6f9b2479022";
            //sToken = "dea3a5e2032a408441f6248b0ba30cd4";

            //provide all the required parameters for HTTP Client
            objectClass.HttpHost = sHost;
            objectClass.ServiceVersion = sVersion;
            objectClass.PrivateKey = sPrivateKey;
            objectClass.Token = sToken;
            objectClass.SecureURL = sSecureURL;
            objectClass.ContentType = sContentType;
            
            
            //Specify the type of Rest API
            objectClass.Type = GetRestAPIType(RestAPIType.CustomerGroup);


            //GET
            
            //objectClass.ID = 2;
            CallFunctions(null, objectClass, ActionType.Get, RestAPIType.CustomerGroup);

            
            //POST

            //Customer RecordToAdd = new Customer() { Email = "*****@*****.**", Password = "******", BillingFirstName = "Mark", BillingLastName = "Adams" };
            CustomerGroup RecordToAdd = new CustomerGroup() { Name = "AnotherCustomerGroup121615_01", Description = "CustomerGroup121615_01" };
            CallFunctions(RecordToAdd, objectClass, ActionType.Add, RestAPIType.CustomerGroup);
            Type a = typeof(CustomerGroup);

            
            //PUT
            objectClass.ID = 2;
            //Customer RecordToUpdate = new Customer() { BillingFirstName = "Andrew", BillingLastName = "Williams", CustomerID = objectClass.ID };
            CustomerGroup RecordToUpdate = new CustomerGroup() { CustomerGroupID = objectClass.ID, Description="SupportCustomers" };
            CallFunctions(RecordToUpdate, objectClass, ActionType.Update, RestAPIType.CustomerGroup);
            

            //DELETE
            objectClass.ID = 4;
            //CallFunctions(null, objectClass, ActionType.Delete );

        }